提交 0c631db0 编写于 作者: J jp9000

UI: Add funcs to get windows ver. and disable aero

Adds two functions, GetWindowsVersion and SetAeroEnabled.
上级 9d1204a8
......@@ -28,6 +28,7 @@ using namespace std;
#include <windows.h>
#include <shellapi.h>
#include <shlobj.h>
#include <Dwmapi.h>
static inline bool check_path(const char* data, const char *path,
string &output)
......@@ -159,3 +160,46 @@ vector<string> GetPreferredLocales()
return result;
}
uint32_t GetWindowsVersion()
{
static uint32_t ver = 0;
if (ver == 0) {
OSVERSIONINFOW osvi = {};
osvi.dwOSVersionInfoSize = sizeof(osvi);
if (GetVersionExW(&osvi)) {
ver = osvi.dwMajorVersion << 8 | osvi.dwMinorVersion;
}
}
return ver;
}
void SetAeroEnabled(bool enable)
{
static HRESULT (WINAPI *func)(UINT) = nullptr;
static bool failed = false;
if (!func) {
if (failed) {
return;
}
HMODULE dwm = LoadLibraryW(L"dwmapi");
if (!dwm) {
failed = true;
return;
}
func = reinterpret_cast<decltype(func)>(GetProcAddress(dwm,
"DwmEnableComposition"));
if (!func) {
failed = true;
return;
}
}
func(enable ? DWM_EC_ENABLECOMPOSITION : DWM_EC_DISABLECOMPOSITION);
}
......@@ -42,3 +42,8 @@ bool InitApplicationBundle();
std::string GetDefaultVideoSavePath();
std::vector<std::string> GetPreferredLocales();
#ifdef _WIN32
uint32_t GetWindowsVersion();
void SetAeroEnabled(bool enable);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册