Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=39469 Signed-off-by: Joel Leclerc meerkatanonymous@gmail.com --- dlls/dwmapi/Makefile.in | 1 + dlls/dwmapi/dwmapi_main.c | 41 ++++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/dlls/dwmapi/Makefile.in b/dlls/dwmapi/Makefile.in index 3a3691326f..ebdd3aae05 100644 --- a/dlls/dwmapi/Makefile.in +++ b/dlls/dwmapi/Makefile.in @@ -1,5 +1,6 @@ MODULE = dwmapi.dll IMPORTLIB = dwmapi +IMPORTS = advapi32
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/dwmapi/dwmapi_main.c b/dlls/dwmapi/dwmapi_main.c index 6378a091f0..ede3c49420 100644 --- a/dlls/dwmapi/dwmapi_main.c +++ b/dlls/dwmapi/dwmapi_main.c @@ -26,6 +26,7 @@ #include "winbase.h" #include "wingdi.h" #include "winuser.h" +#include "winreg.h" #include "dwmapi.h" #include "wine/debug.h"
@@ -51,14 +52,40 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) */ HRESULT WINAPI DwmIsCompositionEnabled(BOOL *enabled) { - static int once; - if (!once) - { - FIXME("%p\n", enabled); - once = 1; + static const WCHAR dwn_reg_keyW[] = {'S','o','f','t','w','a','r','e','\', + 'M','i','c','r','o','s','o','f','t','\', + 'W','i','n','d','o','w','s','\', + 'D','W','M','\0'}; + static const WCHAR compositionW[] = {'C','o','m','p','o','s','i','t','i','o','n','\0'}; + + HKEY hkey; + WCHAR buf[12]; + DWORD type, value, count = sizeof(buf); + + if (RegOpenKeyW(HKEY_CURRENT_USER, dwn_reg_keyW, &hkey) != ERROR_SUCCESS) { + goto fail; + } + + if (RegQueryValueExW(hkey, compositionW, NULL, &type, (BYTE *)buf, &count) != ERROR_SUCCESS) { + goto fail; + } + + if (type == REG_DWORD) { + memcpy(&value, buf, sizeof(value)); + } else { + FIXME("Software\Microsoft\Windows\DWM\Composition is not of type DWORD\n"); + goto fail; } - else - TRACE("%p\n", enabled); + + if (value == 1) { + TRACE("*%p = 1\n", enabled); + + *enabled = TRUE; + return S_OK; + } + + fail: + TRACE("*%p = 0\n", enabled);
*enabled = FALSE; return S_OK;
Joel Leclerc meerkatanonymous@gmail.com wrote:
For that particular bug report just making DwmIsCompositionEnabled() return TRUE is enough according to the bug comments, reading the value from registry doesn't add anything useful. Besides, reading a DWORD value from the registry could be done in less lines of code and without passing not initialzied values to the registry APIs.