Alexandre Julliard : imm32: Retrieve the graphics driver name from the registry.

Alexandre Julliard julliard at winehq.org
Tue Oct 22 13:30:42 CDT 2013


Module: wine
Branch: master
Commit: d85b22cbca7f29ee6a80eb1a886e180ab57454cf
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d85b22cbca7f29ee6a80eb1a886e180ab57454cf

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Oct 22 16:15:01 2013 +0200

imm32: Retrieve the graphics driver name from the registry.

---

 dlls/imm32/imm.c |   42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index 4738103..35c16f0 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -32,8 +32,8 @@
 #include "ddk/imm.h"
 #include "winnls.h"
 #include "winreg.h"
-#include "wine/gdi_driver.h"
 #include "wine/list.h"
+#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(imm);
 
@@ -245,6 +245,38 @@ static void IMM_FreeThreadData(void)
     }
 }
 
+static HMODULE load_graphics_driver(void)
+{
+    static const WCHAR display_device_guid_propW[] = {
+        '_','_','w','i','n','e','_','d','i','s','p','l','a','y','_',
+        'd','e','v','i','c','e','_','g','u','i','d',0 };
+    static const WCHAR key_pathW[] = {
+        'S','y','s','t','e','m','\\',
+        'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
+        'C','o','n','t','r','o','l','\\',
+        'V','i','d','e','o','\\','{',0};
+    static const WCHAR displayW[] = {'}','\\','0','0','0','0',0};
+    static const WCHAR driverW[] = {'G','r','a','p','h','i','c','s','D','r','i','v','e','r',0};
+
+    HMODULE ret = 0;
+    HKEY hkey;
+    DWORD size;
+    WCHAR path[MAX_PATH];
+    WCHAR key[(sizeof(key_pathW) + sizeof(displayW)) / sizeof(WCHAR) + 40];
+    UINT guid_atom = HandleToULong( GetPropW( GetDesktopWindow(), display_device_guid_propW ));
+
+    if (!guid_atom) return 0;
+    memcpy( key, key_pathW, sizeof(key_pathW) );
+    if (!GlobalGetAtomNameW( guid_atom, key + strlenW(key), 40 )) return 0;
+    strcatW( key, displayW );
+    if (RegOpenKeyW( HKEY_LOCAL_MACHINE, key, &hkey )) return 0;
+    size = sizeof(path);
+    if (!RegQueryValueExW( hkey, driverW, NULL, NULL, (BYTE *)path, &size )) ret = LoadLibraryW( path );
+    RegCloseKey( hkey );
+    TRACE( "%s %p\n", debugstr_w(path), ret );
+    return ret;
+}
+
 /* ImmHkl loading and freeing */
 #define LOAD_FUNCPTR(f) if((ptr->p##f = (LPVOID)GetProcAddress(ptr->hIME, #f)) == NULL){WARN("Can't find function %s in ime\n", #f);}
 static ImmHkl *IMM_GetImmHkl(HKL hkl)
@@ -265,13 +297,7 @@ static ImmHkl *IMM_GetImmHkl(HKL hkl)
 
     ptr->hkl = hkl;
     if (ImmGetIMEFileNameW(hkl, filename, MAX_PATH)) ptr->hIME = LoadLibraryW(filename);
-    if (!ptr->hIME)
-    {
-        HDC hdc = GetDC( 0 );
-        GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
-                            (LPCWSTR)__wine_get_driver_module( hdc ), &ptr->hIME );
-        ReleaseDC( 0, hdc );
-    }
+    if (!ptr->hIME) ptr->hIME = load_graphics_driver();
     if (ptr->hIME)
     {
         LOAD_FUNCPTR(ImeInquire);




More information about the wine-cvs mailing list