diff --git a/obs/platform-windows.cpp b/obs/platform-windows.cpp index 5686a1966..5bceb2f04 100644 --- a/obs/platform-windows.cpp +++ b/obs/platform-windows.cpp @@ -28,6 +28,7 @@ using namespace std; #include #include #include +#include static inline bool check_path(const char* data, const char *path, string &output) @@ -159,3 +160,46 @@ vector 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(GetProcAddress(dwm, + "DwmEnableComposition")); + if (!func) { + failed = true; + return; + } + } + + func(enable ? DWM_EC_ENABLECOMPOSITION : DWM_EC_DISABLECOMPOSITION); +} diff --git a/obs/platform.hpp b/obs/platform.hpp index b180adee3..30a6ae33d 100644 --- a/obs/platform.hpp +++ b/obs/platform.hpp @@ -42,3 +42,8 @@ bool InitApplicationBundle(); std::string GetDefaultVideoSavePath(); std::vector GetPreferredLocales(); + +#ifdef _WIN32 +uint32_t GetWindowsVersion(); +void SetAeroEnabled(bool enable); +#endif