anotherim-desktop/plugins/windows-notification/api/include/win32.hpp

48 lines
1 KiB
C++
Raw Normal View History

2021-03-26 11:22:55 +00:00
#pragma once
#include <glib.h>
#ifdef __cplusplus
#include <string>
#include <cstdint>
#include <exception>
#include <iterator>
#include "make_array.hpp"
#include "hexify.hpp"
struct win32_error : std::exception
{
std::uint32_t code;
explicit win32_error() noexcept; // initializes with GetLastError()
explicit win32_error(const std::uint32_t code) noexcept
: code{code}
{}
const char *what() const noexcept override
{
// NOTE: thread-unsafe
// TODO: decimal representation seems to be more usual for win32 errors
msg = make_array("win32 error 0x01234567\0");
hexify32(code, std::end(msg)-1);
return std::data(msg);
}
private:
mutable std::array<char,22+1> msg;
};
2021-03-26 11:22:55 +00:00
2021-03-05 22:44:05 +00:00
std::wstring GetExePath();
2021-03-05 22:50:36 +00:00
std::wstring GetEnv(const wchar_t *variable_name);
2021-03-26 11:22:55 +00:00
#define EXTERN extern "C"
#define NOEXCEPT noexcept
#else
#define EXTERN
#define NOEXCEPT
2021-03-26 11:22:55 +00:00
#endif
2021-03-05 22:15:09 +00:00
EXTERN gboolean IsWindows10() NOEXCEPT;
EXTERN gboolean SetProcessAumid(const gchar* aumid) NOEXCEPT;
#undef EXTERN
#undef NOEXCEPT