Zebediah Figura : winspool: Remove the "force" parameter to WINSPOOL_SetDefaultPrinter().

Alexandre Julliard julliard at winehq.org
Thu Jul 23 16:36:56 CDT 2020


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon Jul 20 21:50:47 2020 -0500

winspool: Remove the "force" parameter to WINSPOOL_SetDefaultPrinter().

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winspool.drv/info.c | 35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index 1a8d572f43..d46fefc461 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -555,30 +555,19 @@ static DWORD WINSPOOL_GetOpenedPrinterRegKey(HANDLE hPrinter, HKEY *phkey)
     return open_printer_reg_key( name, phkey );
 }
 
-static void
-WINSPOOL_SetDefaultPrinter(const char *devname, const char *name, BOOL force) {
-    char qbuf[200];
+static void set_default_printer(const char *devname, const char *name)
+{
+    char *buf = HeapAlloc(GetProcessHeap(), 0, strlen(name)+strlen(devname)+strlen(",WINEPS.DRV,LPR:")+1);
+    HKEY hkey;
 
-    /* If forcing, or no profile string entry for device yet, set the entry
-     *
-     * The always change entry if not WINEPS yet is discussable.
-     */
-    if (force								||
-	!GetProfileStringA("windows","device","*",qbuf,sizeof(qbuf))	||
-	!strcmp(qbuf,"*")						||
-	!strstr(qbuf,"WINEPS.DRV")
-    ) {
-    	char *buf = HeapAlloc(GetProcessHeap(),0,strlen(name)+strlen(devname)+strlen(",WINEPS.DRV,LPR:")+1);
-        HKEY hkey;
-
-	sprintf(buf,"%s,WINEPS.DRV,LPR:%s",devname,name);
-	WriteProfileStringA("windows","device",buf);
-        if(RegCreateKeyW(HKEY_CURRENT_USER, user_default_reg_key, &hkey) == ERROR_SUCCESS) {
-            RegSetValueExA(hkey, "Device", 0, REG_SZ, (LPBYTE)buf, strlen(buf) + 1);
-            RegCloseKey(hkey);
-        }
-	HeapFree(GetProcessHeap(),0,buf);
+    sprintf(buf, "%s,WINEPS.DRV,LPR:%s", devname, name);
+    WriteProfileStringA("windows","device", buf);
+    if (!RegCreateKeyW(HKEY_CURRENT_USER, user_default_reg_key, &hkey))
+    {
+        RegSetValueExA(hkey, "Device", 0, REG_SZ, (BYTE *)buf, strlen(buf) + 1);
+        RegCloseKey(hkey);
     }
+    HeapFree(GetProcessHeap(), 0, buf);
 }
 
 static BOOL add_printer_driver(const WCHAR *name, WCHAR *ppd)
@@ -1273,7 +1262,7 @@ static BOOL PRINTCAP_ParseEntry( const char *pent, BOOL isfirst )
     }
 
     if (isfirst || set_default)
-        WINSPOOL_SetDefaultPrinter(devname,name,TRUE);
+        set_default_printer(devname, name);
 
  end:
     if (hkeyPrinters) RegCloseKey( hkeyPrinters );




More information about the wine-cvs mailing list