forked from Soreepeong/XivAlexander
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils_Win32.h
46 lines (33 loc) · 1.42 KB
/
Utils_Win32.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <windef.h>
namespace Utils::Win32 {
void SetThreadDescription(HANDLE hThread, const std::wstring& description);
template <typename ... Args>
void SetThreadDescription(HANDLE hThread, const wchar_t* format, Args ... args) {
SetThreadDescription(hThread, std::format(format, std::forward<Args>(args)...));
}
template <typename ... Args>
int MessageBoxF(HWND hWnd, UINT uType, const wchar_t* lpCaption, const wchar_t* format, Args ... args) {
return MessageBoxW(hWnd, std::format(format, std::forward<Args>(args)...).c_str(), lpCaption, uType);
}
void SetMenuState(HMENU hMenu, DWORD nMenuId, bool bChecked);
void SetMenuState(HWND hWnd, DWORD nMenuId, bool bChecked);
std::string FormatWindowsErrorMessage(unsigned int errorCode);
std::pair<std::string, std::string> FormatModuleVersionString(HMODULE hModule);
BOOL EnableTokenPrivilege(HANDLE hToken, LPCTSTR Privilege, BOOL bEnablePrivilege);
void AddDebugPrivilege();
class Error : public std::runtime_error {
const int m_nErrorCode;
public:
Error(int errorCode, const std::string& msg);
explicit Error(const std::string& msg);
template<typename ... Args>
explicit Error(const char* format, Args...args)
: Error(std::format(format, std::forward<Args>(args)...)) {
}
template<typename ... Args>
Error(int errorCode, const char* format, Args...args)
: Error(errorCode, std::format(format, std::forward<Args>(args)...)) {
}
};
}