Signed-off-by: Joel Leclerc meerkatanonymous@gmail.com --- v2: Ensure the registry key is closed, small refactor --- dlls/dwmapi/Makefile.in | 1 + dlls/dwmapi/dwmapi_main.c | 27 ++++++++++++++++++++------- 2 files changed, 21 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..3a8a5ab856 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,16 +52,28 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) */ HRESULT WINAPI DwmIsCompositionEnabled(BOOL *enabled) { - static int once; - if (!once) + 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; + DWORD type, value, count = sizeof(value); + + *enabled = FALSE; + + if (RegOpenKeyW(HKEY_CURRENT_USER, dwn_reg_keyW, &hkey) == ERROR_SUCCESS) { - FIXME("%p\n", enabled); - once = 1; + if (RegQueryValueExW(hkey, compositionW, NULL, &type, &value, &count) == ERROR_SUCCESS && + type == REG_DWORD) + { + if (value == 1) *enabled = TRUE; + } + RegCloseKey(hkey); } - else - TRACE("%p\n", enabled);
- *enabled = FALSE; + TRACE("*%p = %i\n", enabled, *enabled); return S_OK; }
Hi Joel,
Just so you know, DwmIsCompositionEnabled always return TRUE on Windows 8. So it shouldn't be that much of a problem only setting *enabled to TRUE.
If you are seriously thinking about a more complete implementation. You should also consider implementing DwmEnableComposition and related functions and some tests.
Thanks, Zhiyi
On 10/3/19 8:14 PM, Joel Leclerc wrote:
Signed-off-by: Joel Leclerc meerkatanonymous@gmail.com
v2: Ensure the registry key is closed, small refactor
dlls/dwmapi/Makefile.in | 1 + dlls/dwmapi/dwmapi_main.c | 27 ++++++++++++++++++++------- 2 files changed, 21 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..3a8a5ab856 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,16 +52,28 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) */ HRESULT WINAPI DwmIsCompositionEnabled(BOOL *enabled) {
- static int once;
- if (!once)
- 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;
- DWORD type, value, count = sizeof(value);
- *enabled = FALSE;
- if (RegOpenKeyW(HKEY_CURRENT_USER, dwn_reg_keyW, &hkey) == ERROR_SUCCESS) {
FIXME("%p\n", enabled);
once = 1;
if (RegQueryValueExW(hkey, compositionW, NULL, &type, &value, &count) == ERROR_SUCCESS &&
type == REG_DWORD)
{
if (value == 1) *enabled = TRUE;
}
}RegCloseKey(hkey);
else
TRACE("%p\n", enabled);
*enabled = FALSE;
- TRACE("*%p = %i\n", enabled, *enabled); return S_OK;
}
Just so you know, DwmIsCompositionEnabled always return TRUE on Windows 8. So it shouldn't be that much of a problem only setting *enabled to TRUE.
Thank you, I forgot to check MSDN's documentation before writing the patch. I've submitted v3.
You should also consider implementing DwmEnableComposition
According to MSDN however, DwmEnableComposition has no effect under Windows 8?
As for the others, I agree, I'll try to get around to it if I can find more programs using it to test. Enabling it will cause some programs to assume various functions will exist, so I think at least stubbing the DLL is likely going to be important.
Thanks for the review.