Re: WinSpool Ordinal Addition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On January 6, 2002 03:26 pm, Alexandre Julliard wrote:
> None of the winspool.drv I checked have
> PrinterProperties at ordinal 201, so I don't see how this could work.
> Or does it just want to have something there?  does it work if you put
> a stub at 201 instead of PrinterProperties?

No idea why it was working; mind you, I didn't test printing - only tried to 
get it to start up. I guess this is what happens when I look at someone's 
patch instead of checking the .dll directly. :>

In Windows 2000 (and I presume later), winspool.drv has some new functions. 
The one this application is looking for turns out to be GetDefaultPrinter() 
(ASCII version is ordinal 201, Unicode is 203). I've added the ASCII and 
Unicode implementations of that function to winspool in the attached patch. 
The ASCII version has been tested; I'd appreciate it if you could take a 
glance at the Unicode version and see if I got the conversions correct.

The application will now open the 'printer setup' dialog, instead of 
returning an error.

//Mark

ChangeLog:
Mark G. Adams <mgadams@sympatico.ca>
Add GetDefaultPrinter() functions to winspool.drv
Index: winspool.h
===================================================================
RCS file: /home/wine/wine/include/winspool.h,v
retrieving revision 1.19
diff -u -u -r1.19 winspool.h
--- winspool.h	2001/02/21 04:00:40	1.19
+++ winspool.h	2002/01/07 04:31:43
@@ -888,6 +888,10 @@
 				LPDWORD pcbNeeded, LPDWORD pcbReturned);
 #define EnumPrinterDrivers WINELIB_NAME_AW(EnumPrinterDrivers)
 
+BOOL WINAPI GetDefaultPrinterA(LPSTR pName, LPDWORD pcbNameSize);
+BOOL WINAPI GetDefaultPrinterW(LPWSTR pName, LPDWORD pcbNameSize);
+#define GetDefaultPrinter WINELIB_NAME_AW(GetDefaultPrinter)
+
 BOOL WINAPI DeletePrinterDriverA(LPSTR pName, LPSTR pEnvironment,
 				 LPSTR pDriverName);
 BOOL WINAPI DeletePrinterDriverW(LPWSTR pName, LPWSTR pEnvironment,
Index: info.c
===================================================================
RCS file: /home/wine/wine/dlls/winspool/info.c,v
retrieving revision 1.46
diff -u -u -r1.46 info.c
--- info.c	2001/10/28 21:16:38	1.46
+++ info.c	2002/01/07 04:32:14
@@ -2687,6 +2687,71 @@
 }
 
 /******************************************************************************
+ *		GetDefaultPrinterA   (WINSPOOL.201)
+ * Added in Windows 2000
+ * Based on PRINTDLG_GetDefaultPrinterName in dlls/commdlg/printdlg.c
+ */
+BOOL WINAPI GetDefaultPrinterA(LPSTR name, LPDWORD namesize)
+{
+   char *ptr;
+
+   if (*namesize < 1)
+   {
+      SetLastError (ERROR_INSUFFICIENT_BUFFER);
+      return FALSE;
+   }
+
+   if (!GetProfileStringA ("windows", "device", "", name, *namesize))
+   {
+      SetLastError (ERROR_FILE_NOT_FOUND);
+      return FALSE;
+   }
+
+   if ((ptr = strchr (name, ',')) == NULL)
+   {
+      SetLastError (ERROR_FILE_NOT_FOUND);
+      return FALSE;
+   }
+
+   *ptr = '\0';
+   *namesize = strlen (name) + 1;
+   return TRUE;
+}
+
+
+/******************************************************************************
+ *		GetDefaultPrinterW   (WINSPOOL.203)
+ * Added in Windows 2000
+ */
+BOOL WINAPI GetDefaultPrinterW(LPWSTR name, LPDWORD namesize)
+{
+   char *buf;
+   BOOL  ret;
+
+   if (*namesize < 1)
+   {
+      SetLastError (ERROR_INSUFFICIENT_BUFFER);
+      return FALSE;
+   }
+
+   buf = HeapAlloc (GetProcessHeap (), 0, *namesize);
+   ret = GetDefaultPrinterA (buf, namesize);
+
+   if (ret == TRUE)
+   {
+      if (MultiByteToWideChar (CP_ACP, 0, buf, -1, name, *namesize) == 0)
+      {
+         SetLastError (ERROR_INSUFFICIENT_BUFFER);
+         ret = FALSE;
+      }
+   }
+
+   HeapFree (GetProcessHeap (), 0, buf);
+   return ret;
+}
+
+
+/******************************************************************************
  *		SetPrinterDataExA   (WINSPOOL.@)
  */
 DWORD WINAPI SetPrinterDataExA(HANDLE hPrinter, LPSTR pKeyName,
Index: winspool.drv.spec
===================================================================
RCS file: /home/wine/wine/dlls/winspool/winspool.drv.spec,v
retrieving revision 1.10
diff -u -u -r1.10 winspool.drv.spec
--- winspool.drv.spec	2001/02/21 04:00:40	1.10
+++ winspool.drv.spec	2002/01/07 04:32:14
@@ -86,6 +86,8 @@
 @ stub EnumPrinterDataW
 @ stdcall EnumPrinterDriversA(str str long ptr long ptr ptr) EnumPrinterDriversA
 @ stdcall EnumPrinterDriversW(wstr wstr long ptr long ptr ptr) EnumPrinterDriversW
+201 stdcall GetDefaultPrinterA(str ptr) GetDefaultPrinterA
+203 stdcall GetDefaultPrinterW(wstr ptr) GetDefaultPrinterW
 @ stdcall EnumPrintersA(long ptr long ptr long ptr ptr) EnumPrintersA
 @ stdcall EnumPrintersW(long ptr long ptr long ptr ptr) EnumPrintersW
 @ stub ExtDeviceMode

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux