gdi32: first look for a printer driver name in the registry (fix eterbug #5744)
authorVitaly Perov <vitperov@etersoft.ru>
Tue, 22 Feb 2011 14:24:04 +0000 (17:24 +0300)
committerTest Robot <wine-patches-test@office.etersoft.ru>
Tue, 22 Feb 2011 14:33:17 +0000 (17:33 +0300)
dlls/gdi32/driver.c

index 38c4942bcd0b85dc6f02563fa28acfdfeed27b31..e8ef08b24080f7b263e1b223b2a3f02dea85472d 100644 (file)
@@ -322,8 +322,14 @@ BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
     static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
     static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
     static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
+    static const WCHAR user_printers_reg_key[] = { 'S','o','f','t','w','a','r','e','\\',
+                                               'M','i','c','r','o','s','o','f','t','\\',
+                                               'W','i','n','d','o','w','s',' ','N','T','\\',
+                                               'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
+                                               'D','e','v','i','c','e','s',0};
     static const WCHAR empty_strW[] = { 0 };
     WCHAR *p;
+    HKEY hKey;
 
     /* display is a special case */
     if (!strcmpiW( device, displayW ) ||
@@ -333,8 +339,14 @@ BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
         return TRUE;
     }
 
-    size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
-    if(!size) {
+    if (!RegOpenKeyExW(HKEY_CURRENT_USER, user_printers_reg_key, 0, KEY_READ, &hKey)
+        && !RegQueryValueExW(hKey, device, NULL, NULL, (LPBYTE) driver, &size))
+    {
+        TRACE("Get value from registry\n");
+        RegCloseKey(hKey);
+    }
+    else if (!GetProfileStringW(devicesW, device, empty_strW, driver, size))
+    {
         WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
         return FALSE;
     }