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

Adds two functions, GetWindowsVersion and SetAeroEnabled.
master
jp9000 2015-05-25 01:34:49 -07:00
parent 9d1204a8bc
commit 0c631db046
2 changed files with 49 additions and 0 deletions

View File

@ -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);
}

View File

@ -42,3 +42,8 @@ bool InitApplicationBundle();
std::string GetDefaultVideoSavePath();
std::vector<std::string> GetPreferredLocales();
#ifdef _WIN32
uint32_t GetWindowsVersion();
void SetAeroEnabled(bool enable);
#endif