4 * Copyright 1996 John Harvey
5 * Copyright 1998 Andreas Mohr
6 * Copyright 1999 Klaas van Gend, Huw D M Davies
16 #include "debugtools.h"
20 DEFAULT_DEBUG_CHANNEL(winspool
)
22 CRITICAL_SECTION PRINT32_RegistryBlocker
;
24 typedef struct _OPENEDPRINTERA
28 LPPRINTER_DEFAULTSA lpDefault
;
29 } OPENEDPRINTERA
, *LPOPENEDPRINTERA
;
31 /* The OpenedPrinter Table dynamic array */
32 static HDPA pOpenedPrinterDPA
= NULL
;
34 extern HDPA (WINAPI
* WINSPOOL_DPA_CreateEx
) (INT
, HANDLE
);
35 extern LPVOID (WINAPI
* WINSPOOL_DPA_GetPtr
) (const HDPA
, INT
);
36 extern INT (WINAPI
* WINSPOOL_DPA_InsertPtr
) (const HDPA
, INT
, LPVOID
);
38 static char Printers
[] =
39 "System\\CurrentControlSet\\control\\Print\\Printers\\";
40 static char Drivers
[] =
41 "System\\CurrentControlSet\\control\\Print\\Environments\\Windows 4.0\\Drivers\\"; /* Hmm, well */
43 /******************************************************************
44 * WINSPOOL_GetOpenedPrinterEntryA
45 * Get the first place empty in the opened printer table
47 static LPOPENEDPRINTERA
WINSPOOL_GetOpenedPrinterEntryA()
50 LPOPENEDPRINTERA pOpenedPrinter
;
53 * Create the opened printers' handle dynamic array.
55 if (!pOpenedPrinterDPA
)
57 pOpenedPrinterDPA
= WINSPOOL_DPA_CreateEx(10, GetProcessHeap());
58 for (i
= 0; i
< 10; i
++)
60 pOpenedPrinter
= HeapAlloc(GetProcessHeap(),
62 sizeof(OPENEDPRINTERA
));
63 pOpenedPrinter
->hPrinter
= -1;
64 WINSPOOL_DPA_InsertPtr(pOpenedPrinterDPA
, i
, pOpenedPrinter
);
69 * Search for a handle not yet allocated.
71 for (i
= 0; i
< pOpenedPrinterDPA
->nItemCount
; i
++)
73 pOpenedPrinter
= WINSPOOL_DPA_GetPtr(pOpenedPrinterDPA
, i
);
75 if (pOpenedPrinter
->hPrinter
== -1)
77 pOpenedPrinter
->hPrinter
= i
+ 1;
78 return pOpenedPrinter
;
83 * Didn't find one, insert new element in the array.
85 if (i
== pOpenedPrinterDPA
->nItemCount
)
87 pOpenedPrinter
= HeapAlloc(GetProcessHeap(),
89 sizeof(OPENEDPRINTERA
));
90 pOpenedPrinter
->hPrinter
= i
+ 1;
91 WINSPOOL_DPA_InsertPtr(pOpenedPrinterDPA
, i
, pOpenedPrinter
);
92 return pOpenedPrinter
;
98 /******************************************************************
99 * WINSPOOL_GetOpenedPrinterA
100 * Get the pointer to the opened printer referred by the handle
102 static LPOPENEDPRINTERA
WINSPOOL_GetOpenedPrinterA(int printerHandle
)
104 LPOPENEDPRINTERA pOpenedPrinter
;
106 if(!pOpenedPrinterDPA
) return NULL
;
107 if((printerHandle
<=0) ||
108 (printerHandle
> (pOpenedPrinterDPA
->nItemCount
- 1)))
111 pOpenedPrinter
= WINSPOOL_DPA_GetPtr(pOpenedPrinterDPA
, printerHandle
-1);
113 return pOpenedPrinter
;
116 /******************************************************************
117 * DeviceCapabilities32A [WINSPOOL.151]
120 INT WINAPI
DeviceCapabilitiesA(LPCSTR pDeivce
,LPCSTR pPort
, WORD cap
,
121 LPSTR pOutput
, LPDEVMODEA lpdm
)
124 ret
= GDI_CallDeviceCapabilities16(pDeivce
, pPort
, cap
, pOutput
, lpdm
);
126 /* If DC_PAPERSIZE map POINT16s to POINTs */
127 if(ret
!= -1 && cap
== DC_PAPERSIZE
&& pOutput
) {
128 POINT16
*tmp
= HeapAlloc( GetProcessHeap(), 0, ret
* sizeof(POINT16
) );
130 memcpy(tmp
, pOutput
, ret
* sizeof(POINT16
));
131 for(i
= 0; i
< ret
; i
++)
132 CONV_POINT16TO32(tmp
+ i
, (POINT
*)pOutput
+ i
);
133 HeapFree( GetProcessHeap(), 0, tmp
);
139 /*****************************************************************************
140 * DeviceCapabilities32W
142 INT WINAPI
DeviceCapabilitiesW(LPCWSTR pDevice
, LPCWSTR pPort
,
143 WORD fwCapability
, LPWSTR pOutput
,
144 const DEVMODEW
*pDevMode
)
146 FIXME("(%p,%p,%d,%p,%p): stub\n",
147 pDevice
, pPort
, fwCapability
, pOutput
, pDevMode
);
151 /******************************************************************
152 * DocumentProperties32A [WINSPOOL.155]
155 LONG WINAPI
DocumentPropertiesA(HWND hWnd
,HANDLE hPrinter
,
156 LPSTR pDeviceName
, LPDEVMODEA pDevModeOutput
,
157 LPDEVMODEA pDevModeInput
,DWORD fMode
)
159 LPOPENEDPRINTERA lpOpenedPrinter
;
160 LPSTR lpName
= pDeviceName
;
162 TRACE("(%d,%d,%s,%p,%p,%ld)\n",
163 hWnd
,hPrinter
,pDeviceName
,pDevModeOutput
,pDevModeInput
,fMode
167 lpOpenedPrinter
= WINSPOOL_GetOpenedPrinterA(hPrinter
);
168 if(!lpOpenedPrinter
) {
169 SetLastError(ERROR_INVALID_HANDLE
);
172 lpName
= lpOpenedPrinter
->lpsPrinterName
;
175 return GDI_CallExtDeviceMode16(hWnd
, pDevModeOutput
, lpName
, "LPT1:",
176 pDevModeInput
, NULL
, fMode
);
181 /*****************************************************************************
182 * DocumentProperties32W
184 LONG WINAPI
DocumentPropertiesW(HWND hWnd
, HANDLE hPrinter
,
186 LPDEVMODEW pDevModeOutput
,
187 LPDEVMODEW pDevModeInput
, DWORD fMode
)
189 FIXME("(%d,%d,%s,%p,%p,%ld): stub\n",
190 hWnd
,hPrinter
,debugstr_w(pDeviceName
),pDevModeOutput
,pDevModeInput
,
196 /******************************************************************
197 * OpenPrinter32A [WINSPOOL.196]
200 BOOL WINAPI
OpenPrinterA(LPSTR lpPrinterName
,HANDLE
*phPrinter
,
201 LPPRINTER_DEFAULTSA pDefault
)
203 /* Not implemented: use the DesiredAccess of pDefault to set
204 the access rights to the printer */
206 LPOPENEDPRINTERA lpOpenedPrinter
;
207 HKEY hkeyPrinters
, hkeyPrinter
;
209 TRACE("(printerName: %s, pDefault %p\n", lpPrinterName
, pDefault
);
211 /* Check Printer exists */
212 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Printers
, &hkeyPrinters
) !=
214 ERR("Can't create Printers key\n");
215 SetLastError(ERROR_FILE_NOT_FOUND
); /* ?? */
219 if(RegOpenKeyA(hkeyPrinters
, lpPrinterName
, &hkeyPrinter
)
221 WARN("Can't find printer `%s' in registry\n", lpPrinterName
);
222 RegCloseKey(hkeyPrinters
);
223 SetLastError(ERROR_INVALID_PARAMETER
);
226 RegCloseKey(hkeyPrinter
);
227 RegCloseKey(hkeyPrinters
);
229 if(!phPrinter
) /* This seems to be what win95 does anyway */
232 /* Get a place in the opened printer buffer*/
233 lpOpenedPrinter
= WINSPOOL_GetOpenedPrinterEntryA();
234 if(!lpOpenedPrinter
) {
235 ERR("Can't allocate printer slot\n");
236 SetLastError(ERROR_OUTOFMEMORY
);
240 /* Get the name of the printer */
241 lpOpenedPrinter
->lpsPrinterName
=
242 HEAP_strdupA( GetProcessHeap(), 0, lpPrinterName
);
244 /* Get the unique handle of the printer*/
245 *phPrinter
= lpOpenedPrinter
->hPrinter
;
247 if (pDefault
!= NULL
) {
248 lpOpenedPrinter
->lpDefault
=
249 HeapAlloc(GetProcessHeap(), 0, sizeof(PRINTER_DEFAULTSA
));
250 lpOpenedPrinter
->lpDefault
->pDevMode
=
251 HeapAlloc(GetProcessHeap(), 0, sizeof(DEVMODEA
));
252 memcpy(lpOpenedPrinter
->lpDefault
->pDevMode
, pDefault
->pDevMode
,
254 lpOpenedPrinter
->lpDefault
->pDatatype
=
255 HEAP_strdupA( GetProcessHeap(), 0, pDefault
->pDatatype
);
256 lpOpenedPrinter
->lpDefault
->DesiredAccess
=
257 pDefault
->DesiredAccess
;
264 /******************************************************************
265 * OpenPrinter32W [WINSPOOL.197]
268 BOOL WINAPI
OpenPrinterW(LPWSTR lpPrinterName
,HANDLE
*phPrinter
,
269 LPPRINTER_DEFAULTSW pDefault
)
271 FIXME("(%s,%p,%p):stub\n",debugstr_w(lpPrinterName
), phPrinter
,
273 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
277 /******************************************************************
278 * AddMonitor32A [WINSPOOL.107]
281 BOOL WINAPI
AddMonitorA(LPSTR pName
, DWORD Level
, LPBYTE pMonitors
)
283 FIXME("(%s,%lx,%p):stub!\n", pName
, Level
, pMonitors
);
284 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
288 /******************************************************************
289 * DeletePrinterDriver32A [WINSPOOL.146]
293 DeletePrinterDriverA (LPSTR pName
, LPSTR pEnvironment
, LPSTR pDriverName
)
295 FIXME("(%s,%s,%s):stub\n",debugstr_a(pName
),debugstr_a(pEnvironment
),
296 debugstr_a(pDriverName
));
297 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
302 /******************************************************************
303 * DeleteMonitor32A [WINSPOOL.135]
307 DeleteMonitorA (LPSTR pName
, LPSTR pEnvironment
, LPSTR pMonitorName
)
309 FIXME("(%s,%s,%s):stub\n",debugstr_a(pName
),debugstr_a(pEnvironment
),
310 debugstr_a(pMonitorName
));
311 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
316 /******************************************************************
317 * DeletePort32A [WINSPOOL.137]
321 DeletePortA (LPSTR pName
, HWND hWnd
, LPSTR pPortName
)
323 FIXME("(%s,0x%08x,%s):stub\n",debugstr_a(pName
),hWnd
,
324 debugstr_a(pPortName
));
325 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
329 /******************************************************************************
330 * SetPrinter32W [WINSPOOL.214]
340 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
344 /******************************************************************************
345 * WritePrinter32 [WINSPOOL.223]
355 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
359 /*****************************************************************************
360 * AddForm32A [WINSPOOL.103]
362 BOOL WINAPI
AddFormA(HANDLE hPrinter
, DWORD Level
, LPBYTE pForm
)
364 FIXME("(%d,%ld,%p): stub\n", hPrinter
, Level
, pForm
);
368 /*****************************************************************************
369 * AddForm32W [WINSPOOL.104]
371 BOOL WINAPI
AddFormW(HANDLE hPrinter
, DWORD Level
, LPBYTE pForm
)
373 FIXME("(%d,%ld,%p): stub\n", hPrinter
, Level
, pForm
);
377 /*****************************************************************************
378 * AddJob32A [WINSPOOL.105]
380 BOOL WINAPI
AddJobA(HANDLE hPrinter
, DWORD Level
, LPBYTE pData
,
381 DWORD cbBuf
, LPDWORD pcbNeeded
)
383 FIXME("(%d,%ld,%p,%ld,%p): stub\n", hPrinter
, Level
, pData
, cbBuf
,
388 /*****************************************************************************
389 * AddJob32W [WINSPOOL.106]
391 BOOL WINAPI
AddJobW(HANDLE hPrinter
, DWORD Level
, LPBYTE pData
, DWORD cbBuf
,
394 FIXME("(%d,%ld,%p,%ld,%p): stub\n", hPrinter
, Level
, pData
, cbBuf
,
399 /*****************************************************************************
400 * AddPrinter32A [WINSPOOL.117]
402 HANDLE WINAPI
AddPrinterA(LPSTR pName
, DWORD Level
, LPBYTE pPrinter
)
404 PRINTER_INFO_2A
*pi
= (PRINTER_INFO_2A
*) pPrinter
;
407 HKEY hkeyPrinter
, hkeyPrinters
, hkeyDriver
, hkeyDrivers
;
409 TRACE("(%s,%ld,%p)\n", pName
, Level
, pPrinter
);
412 FIXME("pName = `%s' - unsupported\n", pName
);
413 SetLastError(ERROR_INVALID_PARAMETER
);
417 WARN("Level = %ld\n", Level
);
418 SetLastError(ERROR_INVALID_LEVEL
);
422 SetLastError(ERROR_INVALID_PARAMETER
);
425 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Printers
, &hkeyPrinters
) !=
427 ERR("Can't create Printers key\n");
430 if(RegOpenKeyA(hkeyPrinters
, pi
->pPrinterName
, &hkeyPrinter
) ==
432 SetLastError(ERROR_PRINTER_ALREADY_EXISTS
);
433 RegCloseKey(hkeyPrinter
);
434 RegCloseKey(hkeyPrinters
);
437 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Drivers
, &hkeyDrivers
) !=
439 ERR("Can't create Drivers key\n");
440 RegCloseKey(hkeyPrinters
);
443 if(RegOpenKeyA(hkeyDrivers
, pi
->pDriverName
, &hkeyDriver
) !=
445 WARN("Can't find driver `%s'\n", pi
->pDriverName
);
446 RegCloseKey(hkeyPrinters
);
447 RegCloseKey(hkeyDrivers
);
448 SetLastError(ERROR_UNKNOWN_PRINTER_DRIVER
);
451 RegCloseKey(hkeyDriver
);
452 RegCloseKey(hkeyDrivers
);
453 if(strcasecmp(pi
->pPrintProcessor
, "WinPrint")) { /* FIXME */
454 WARN("Can't find processor `%s'\n", pi
->pPrintProcessor
);
455 SetLastError(ERROR_UNKNOWN_PRINTPROCESSOR
);
456 RegCloseKey(hkeyPrinters
);
459 if(RegCreateKeyA(hkeyPrinters
, pi
->pPrinterName
, &hkeyPrinter
) !=
461 WARN("Can't create printer `%s'\n", pi
->pPrinterName
);
462 SetLastError(ERROR_INVALID_PRINTER_NAME
);
463 RegCloseKey(hkeyPrinters
);
466 RegSetValueExA(hkeyPrinter
, "Attributes", 0, REG_DWORD
,
467 (LPSTR
)&pi
->Attributes
, sizeof(DWORD
));
468 RegSetValueExA(hkeyPrinter
, "Default DevMode", 0, REG_BINARY
,
469 (LPSTR
)&pi
->pDevMode
,
470 pi
->pDevMode
? pi
->pDevMode
->dmSize
: 0);
471 RegSetValueExA(hkeyPrinter
, "Description", 0, REG_SZ
, pi
->pComment
, 0);
472 RegSetValueExA(hkeyPrinter
, "Location", 0, REG_SZ
, pi
->pLocation
, 0);
473 RegSetValueExA(hkeyPrinter
, "Name", 0, REG_SZ
, pi
->pPrinterName
, 0);
474 RegSetValueExA(hkeyPrinter
, "Parameters", 0, REG_SZ
, pi
->pParameters
, 0);
475 RegSetValueExA(hkeyPrinter
, "Port", 0, REG_SZ
, pi
->pPortName
, 0);
476 RegSetValueExA(hkeyPrinter
, "Print Processor", 0, REG_SZ
,
477 pi
->pPrintProcessor
, 0);
478 RegSetValueExA(hkeyPrinter
, "Printer Driver", 0, REG_SZ
, pi
->pDriverName
,
480 RegSetValueExA(hkeyPrinter
, "Priority", 0, REG_DWORD
,
481 (LPSTR
)&pi
->Priority
, sizeof(DWORD
));
482 RegSetValueExA(hkeyPrinter
, "Separator File", 0, REG_SZ
, pi
->pSepFile
, 0);
483 RegSetValueExA(hkeyPrinter
, "Share Name", 0, REG_SZ
, pi
->pShareName
, 0);
484 RegSetValueExA(hkeyPrinter
, "Start Time", 0, REG_DWORD
,
485 (LPSTR
)&pi
->StartTime
, sizeof(DWORD
));
486 RegSetValueExA(hkeyPrinter
, "Status", 0, REG_DWORD
,
487 (LPSTR
)&pi
->Status
, sizeof(DWORD
));
488 RegSetValueExA(hkeyPrinter
, "Until Time", 0, REG_DWORD
,
489 (LPSTR
)&pi
->UntilTime
, sizeof(DWORD
));
491 RegCloseKey(hkeyPrinter
);
492 RegCloseKey(hkeyPrinters
);
493 if(!OpenPrinterA(pi
->pPrinterName
, &retval
, NULL
)) {
494 ERR("OpenPrinter failing\n");
500 /*****************************************************************************
501 * AddPrinter32W [WINSPOOL.122]
503 HANDLE WINAPI
AddPrinterW(LPWSTR pName
, DWORD Level
, LPBYTE pPrinter
)
505 FIXME("(%p,%ld,%p): stub\n", pName
, Level
, pPrinter
);
510 /*****************************************************************************
511 * ClosePrinter32 [WINSPOOL.126]
513 BOOL WINAPI
ClosePrinter(HANDLE hPrinter
)
515 LPOPENEDPRINTERA lpOpenedPrinter
;
517 TRACE("Handle %d\n", hPrinter
);
519 if (!pOpenedPrinterDPA
)
522 if ((hPrinter
!= -1) && (hPrinter
< (pOpenedPrinterDPA
->nItemCount
- 1)))
524 lpOpenedPrinter
= WINSPOOL_GetOpenedPrinterA(hPrinter
);
525 HeapFree(GetProcessHeap(), 0, lpOpenedPrinter
->lpsPrinterName
);
526 lpOpenedPrinter
->lpsPrinterName
= NULL
;
528 /* Free the memory of lpDefault if it has been initialized*/
529 if(lpOpenedPrinter
->lpDefault
!= NULL
)
531 HeapFree(GetProcessHeap(), 0,
532 lpOpenedPrinter
->lpDefault
->pDevMode
);
533 HeapFree(GetProcessHeap(), 0,
534 lpOpenedPrinter
->lpDefault
->pDatatype
);
535 HeapFree(GetProcessHeap(), 0,
536 lpOpenedPrinter
->lpDefault
);
537 lpOpenedPrinter
->lpDefault
= NULL
;
540 lpOpenedPrinter
->hPrinter
= -1;
547 /*****************************************************************************
548 * DeleteForm32A [WINSPOOL.133]
550 BOOL WINAPI
DeleteFormA(HANDLE hPrinter
, LPSTR pFormName
)
552 FIXME("(%d,%s): stub\n", hPrinter
, pFormName
);
556 /*****************************************************************************
557 * DeleteForm32W [WINSPOOL.134]
559 BOOL WINAPI
DeleteFormW(HANDLE hPrinter
, LPWSTR pFormName
)
561 FIXME("(%d,%s): stub\n", hPrinter
, debugstr_w(pFormName
));
565 /*****************************************************************************
566 * DeletePrinter32 [WINSPOOL.143]
568 BOOL WINAPI
DeletePrinter(HANDLE hPrinter
)
570 FIXME("(%d): stub\n", hPrinter
);
574 /*****************************************************************************
575 * SetPrinter32A [WINSPOOL.211]
577 BOOL WINAPI
SetPrinterA(HANDLE hPrinter
, DWORD Level
, LPBYTE pPrinter
,
580 FIXME("(%d,%ld,%p,%ld): stub\n",hPrinter
,Level
,pPrinter
,Command
);
584 /*****************************************************************************
585 * SetJob32A [WINSPOOL.209]
587 BOOL WINAPI
SetJobA(HANDLE hPrinter
, DWORD JobId
, DWORD Level
,
588 LPBYTE pJob
, DWORD Command
)
590 FIXME("(%d,%ld,%ld,%p,%ld): stub\n",hPrinter
,JobId
,Level
,pJob
,
595 /*****************************************************************************
596 * SetJob32W [WINSPOOL.210]
598 BOOL WINAPI
SetJobW(HANDLE hPrinter
, DWORD JobId
, DWORD Level
,
599 LPBYTE pJob
, DWORD Command
)
601 FIXME("(%d,%ld,%ld,%p,%ld): stub\n",hPrinter
,JobId
,Level
,pJob
,
606 /*****************************************************************************
607 * GetForm32A [WINSPOOL.181]
609 BOOL WINAPI
GetFormA(HANDLE hPrinter
, LPSTR pFormName
, DWORD Level
,
610 LPBYTE pForm
, DWORD cbBuf
, LPDWORD pcbNeeded
)
612 FIXME("(%d,%s,%ld,%p,%ld,%p): stub\n",hPrinter
,pFormName
,
613 Level
,pForm
,cbBuf
,pcbNeeded
);
617 /*****************************************************************************
618 * GetForm32W [WINSPOOL.182]
620 BOOL WINAPI
GetFormW(HANDLE hPrinter
, LPWSTR pFormName
, DWORD Level
,
621 LPBYTE pForm
, DWORD cbBuf
, LPDWORD pcbNeeded
)
623 FIXME("(%d,%s,%ld,%p,%ld,%p): stub\n",hPrinter
,
624 debugstr_w(pFormName
),Level
,pForm
,cbBuf
,pcbNeeded
);
628 /*****************************************************************************
629 * SetForm32A [WINSPOOL.207]
631 BOOL WINAPI
SetFormA(HANDLE hPrinter
, LPSTR pFormName
, DWORD Level
,
634 FIXME("(%d,%s,%ld,%p): stub\n",hPrinter
,pFormName
,Level
,pForm
);
638 /*****************************************************************************
639 * SetForm32W [WINSPOOL.208]
641 BOOL WINAPI
SetFormW(HANDLE hPrinter
, LPWSTR pFormName
, DWORD Level
,
644 FIXME("(%d,%p,%ld,%p): stub\n",hPrinter
,pFormName
,Level
,pForm
);
648 /*****************************************************************************
649 * ReadPrinter32 [WINSPOOL.202]
651 BOOL WINAPI
ReadPrinter(HANDLE hPrinter
, LPVOID pBuf
, DWORD cbBuf
,
652 LPDWORD pNoBytesRead
)
654 FIXME("(%d,%p,%ld,%p): stub\n",hPrinter
,pBuf
,cbBuf
,pNoBytesRead
);
658 /*****************************************************************************
659 * ResetPrinter32A [WINSPOOL.203]
661 BOOL WINAPI
ResetPrinterA(HANDLE hPrinter
, LPPRINTER_DEFAULTSA pDefault
)
663 FIXME("(%d, %p): stub\n", hPrinter
, pDefault
);
667 /*****************************************************************************
668 * ResetPrinter32W [WINSPOOL.204]
670 BOOL WINAPI
ResetPrinterW(HANDLE hPrinter
, LPPRINTER_DEFAULTSW pDefault
)
672 FIXME("(%d, %p): stub\n", hPrinter
, pDefault
);
677 /*****************************************************************************
678 * WINSPOOL_GetStringFromRegA
680 * Get ValueName from hkey storing result in str. buflen is space left in str
682 static BOOL
WINSPOOL_GetStringFromRegA(HKEY hkey
, LPCSTR ValueName
, LPSTR ptr
,
683 DWORD buflen
, DWORD
*needed
)
685 DWORD sz
= buflen
, type
;
688 ret
= RegQueryValueExA(hkey
, ValueName
, 0, &type
, ptr
, &sz
);
690 if(ret
!= ERROR_SUCCESS
&& ret
!= ERROR_MORE_DATA
) {
691 ERR("Got ret = %ld\n", ret
);
698 /*********************************************************************
699 * WINSPOOL_GetPrinter_2A
701 * Fills out a PRINTER_INFO_2A struct storing the strings in buf.
703 static BOOL
WINSPOOL_GetPrinter_2A(HKEY hkeyPrinter
, PRINTER_INFO_2A
*pi2
,
704 LPBYTE buf
, DWORD cbBuf
, LPDWORD pcbNeeded
)
706 DWORD size
, left
= cbBuf
;
707 BOOL space
= (cbBuf
> 0);
712 WINSPOOL_GetStringFromRegA(hkeyPrinter
, "Name", ptr
, left
, &size
);
713 if(space
&& size
<= left
) {
714 pi2
->pPrinterName
= ptr
;
721 WINSPOOL_GetStringFromRegA(hkeyPrinter
, "Port", ptr
, left
, &size
);
722 if(space
&& size
<= left
) {
723 pi2
->pPortName
= ptr
;
730 WINSPOOL_GetStringFromRegA(hkeyPrinter
, "Printer Driver", ptr
, left
,
732 if(space
&& size
<= left
) {
733 pi2
->pDriverName
= ptr
;
740 WINSPOOL_GetStringFromRegA(hkeyPrinter
, "Default DevMode", ptr
, left
,
742 if(space
&& size
<= left
) {
743 pi2
->pDevMode
= (LPDEVMODEA
)ptr
;
750 WINSPOOL_GetStringFromRegA(hkeyPrinter
, "Print Processor", ptr
, left
,
752 if(space
&& size
<= left
) {
753 pi2
->pPrintProcessor
= ptr
;
760 if(!space
&& pi2
) /* zero out pi2 if we can't completely fill buf */
761 memset(pi2
, 0, sizeof(*pi2
));
766 /*********************************************************************
767 * WINSPOOL_GetPrinter_4A
769 * Fills out a PRINTER_INFO_4A struct storing the strings in buf.
771 static BOOL
WINSPOOL_GetPrinter_4A(HKEY hkeyPrinter
, PRINTER_INFO_4A
*pi4
,
772 LPBYTE buf
, DWORD cbBuf
, LPDWORD pcbNeeded
)
774 DWORD size
, left
= cbBuf
;
775 BOOL space
= (cbBuf
> 0);
780 WINSPOOL_GetStringFromRegA(hkeyPrinter
, "Name", ptr
, left
, &size
);
781 if(space
&& size
<= left
) {
782 pi4
->pPrinterName
= ptr
;
790 if(!space
&& pi4
) /* zero out pi4 if we can't completely fill buf */
791 memset(pi4
, 0, sizeof(*pi4
));
796 /*********************************************************************
797 * WINSPOOL_GetPrinter_5A
799 * Fills out a PRINTER_INFO_5A struct storing the strings in buf.
801 static BOOL
WINSPOOL_GetPrinter_5A(HKEY hkeyPrinter
, PRINTER_INFO_5A
*pi5
,
802 LPBYTE buf
, DWORD cbBuf
, LPDWORD pcbNeeded
)
804 DWORD size
, left
= cbBuf
;
805 BOOL space
= (cbBuf
> 0);
810 WINSPOOL_GetStringFromRegA(hkeyPrinter
, "Name", ptr
, left
, &size
);
811 if(space
&& size
<= left
) {
812 pi5
->pPrinterName
= ptr
;
819 WINSPOOL_GetStringFromRegA(hkeyPrinter
, "Port", ptr
, left
, &size
);
820 if(space
&& size
<= left
) {
821 pi5
->pPortName
= ptr
;
828 if(!space
&& pi5
) /* zero out pi5 if we can't completely fill buf */
829 memset(pi5
, 0, sizeof(*pi5
));
834 /*****************************************************************************
835 * GetPrinterA [WINSPOOL.187]
837 BOOL WINAPI
GetPrinterA(HANDLE hPrinter
, DWORD Level
, LPBYTE pPrinter
,
838 DWORD cbBuf
, LPDWORD pcbNeeded
)
840 OPENEDPRINTERA
*lpOpenedPrinter
;
841 DWORD size
, needed
= 0;
843 HKEY hkeyPrinter
, hkeyPrinters
;
846 TRACE("(%d,%ld,%p,%ld,%p)\n",hPrinter
,Level
,pPrinter
,cbBuf
, pcbNeeded
);
848 lpOpenedPrinter
= WINSPOOL_GetOpenedPrinterA(hPrinter
);
849 if(!lpOpenedPrinter
) {
850 SetLastError(ERROR_INVALID_HANDLE
);
853 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Printers
, &hkeyPrinters
) !=
855 ERR("Can't create Printers key\n");
858 if(RegOpenKeyA(hkeyPrinters
, lpOpenedPrinter
->lpsPrinterName
, &hkeyPrinter
)
860 ERR("Can't find opened printer `%s' in registry\n",
861 lpOpenedPrinter
->lpsPrinterName
);
862 RegCloseKey(hkeyPrinters
);
863 SetLastError(ERROR_INVALID_PRINTER_NAME
); /* ? */
870 PRINTER_INFO_2A
*pi2
= (PRINTER_INFO_2A
*)pPrinter
;
872 size
= sizeof(PRINTER_INFO_2A
);
874 ptr
= pPrinter
+ size
;
876 memset(pPrinter
, 0, size
);
881 ret
= WINSPOOL_GetPrinter_2A(hkeyPrinter
, pi2
, ptr
, cbBuf
, &needed
);
888 PRINTER_INFO_4A
*pi4
= (PRINTER_INFO_4A
*)pPrinter
;
890 size
= sizeof(PRINTER_INFO_4A
);
892 ptr
= pPrinter
+ size
;
894 memset(pPrinter
, 0, size
);
899 ret
= WINSPOOL_GetPrinter_4A(hkeyPrinter
, pi4
, ptr
, cbBuf
, &needed
);
907 PRINTER_INFO_5A
*pi5
= (PRINTER_INFO_5A
*)pPrinter
;
909 size
= sizeof(PRINTER_INFO_5A
);
911 ptr
= pPrinter
+ size
;
913 memset(pPrinter
, 0, size
);
919 ret
= WINSPOOL_GetPrinter_5A(hkeyPrinter
, pi5
, ptr
, cbBuf
, &needed
);
925 FIXME("Unimplemented level %ld\n", Level
);
926 SetLastError(ERROR_INVALID_LEVEL
);
927 RegCloseKey(hkeyPrinters
);
928 RegCloseKey(hkeyPrinter
);
932 RegCloseKey(hkeyPrinter
);
933 RegCloseKey(hkeyPrinters
);
935 if(pcbNeeded
) *pcbNeeded
= needed
;
937 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
942 /*****************************************************************************
943 * GetPrinterW [WINSPOOL.194]
945 BOOL WINAPI
GetPrinterW(HANDLE hPrinter
, DWORD Level
, LPBYTE pPrinter
,
946 DWORD cbBuf
, LPDWORD pcbNeeded
)
948 FIXME("(%d,%ld,%p,%ld,%p): stub\n", hPrinter
, Level
, pPrinter
,
953 /******************************************************************
954 * EnumPrintersA [WINSPOOL.174]
956 * Enumerates the available printers, print servers and print
957 * providers, depending on the specified flags, name and level.
961 * If level is set to 1:
962 * Not implemented yet!
963 * Returns TRUE with an empty list.
965 * If level is set to 2:
966 * Possible flags: PRINTER_ENUM_CONNECTIONS, PRINTER_ENUM_LOCAL.
967 * Returns an array of PRINTER_INFO_2 data structures in the
968 * lpbPrinters buffer. Note that according to MSDN also an
969 * OpenPrinter should be performed on every remote printer.
971 * If level is set to 4 (officially WinNT only):
972 * Possible flags: PRINTER_ENUM_CONNECTIONS, PRINTER_ENUM_LOCAL.
973 * Fast: Only the registry is queried to retrieve printer names,
974 * no connection to the driver is made.
975 * Returns an array of PRINTER_INFO_4 data structures in the
976 * lpbPrinters buffer.
978 * If level is set to 5 (officially WinNT4/Win9x only):
979 * Fast: Only the registry is queried to retrieve printer names,
980 * no connection to the driver is made.
981 * Returns an array of PRINTER_INFO_5 data structures in the
982 * lpbPrinters buffer.
984 * If level set to 3 or 6+:
985 * returns zero (faillure!)
987 * Returns nonzero (TRUE) on succes, or zero on faillure, use GetLastError
991 * - Only PRINTER_ENUM_LOCAL and PRINTER_ENUM_NAME are implemented.
992 * - Only levels 2, 4 and 5 are implemented at the moment.
993 * - 16-bit printer drivers are not enumerated.
994 * - Returned amount of bytes used/needed does not match the real Windoze
995 * implementation (as in this implementation, all strings are part
996 * of the buffer, whereas Win32 keeps them somewhere else)
997 * - At level 2, EnumPrinters should also call OpenPrinter for remote printers.
1000 * - In a regular Wine installation, no registry settings for printers
1001 * exist, which makes this function return an empty list.
1003 BOOL WINAPI
EnumPrintersA(
1004 DWORD dwType
, /* Types of print objects to enumerate */
1005 LPSTR lpszName
, /* name of objects to enumerate */
1006 DWORD dwLevel
, /* type of printer info structure */
1007 LPBYTE lpbPrinters
, /* buffer which receives info */
1008 DWORD cbBuf
, /* max size of buffer in bytes */
1009 LPDWORD lpdwNeeded
, /* pointer to var: # bytes used/needed */
1010 LPDWORD lpdwReturned
/* number of entries returned */
1014 HKEY hkeyPrinters
, hkeyPrinter
;
1015 char PrinterName
[255];
1016 DWORD needed
= 0, number
= 0;
1017 DWORD used
, i
, left
;
1021 memset(lpbPrinters
, 0, cbBuf
);
1025 if (!((dwType
& PRINTER_ENUM_LOCAL
) || (dwType
& PRINTER_ENUM_NAME
))) {
1026 FIXME("dwType = %08lx\n", dwType
);
1027 SetLastError(ERROR_INVALID_FLAGS
);
1031 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Printers
, &hkeyPrinters
) !=
1033 ERR("Can't create Printers key\n");
1037 if(RegQueryInfoKeyA(hkeyPrinters
, NULL
, NULL
, NULL
, &number
, NULL
, NULL
,
1038 NULL
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
) {
1039 RegCloseKey(hkeyPrinters
);
1040 ERR("Can't query Printers key\n");
1043 TRACE("Found %ld printers\n", number
);
1047 RegCloseKey(hkeyPrinters
);
1051 used
= number
* sizeof(PRINTER_INFO_2A
);
1054 used
= number
* sizeof(PRINTER_INFO_4A
);
1057 used
= number
* sizeof(PRINTER_INFO_5A
);
1061 SetLastError(ERROR_INVALID_LEVEL
);
1062 RegCloseKey(hkeyPrinters
);
1065 pi
= (used
<= cbBuf
) ? lpbPrinters
: NULL
;
1067 for(i
= 0; i
< number
; i
++) {
1068 if(RegEnumKeyA(hkeyPrinters
, i
, PrinterName
, sizeof(PrinterName
)) !=
1070 ERR("Can't enum key number %ld\n", i
);
1071 RegCloseKey(hkeyPrinters
);
1074 if(RegOpenKeyA(hkeyPrinters
, PrinterName
, &hkeyPrinter
) !=
1076 ERR("Can't open key '%s'\n", PrinterName
);
1077 RegCloseKey(hkeyPrinters
);
1082 buf
= lpbPrinters
+ used
;
1083 left
= cbBuf
- used
;
1091 WINSPOOL_GetPrinter_2A(hkeyPrinter
, (PRINTER_INFO_2A
*)pi
, buf
,
1094 if(pi
) pi
+= sizeof(PRINTER_INFO_2A
);
1097 WINSPOOL_GetPrinter_4A(hkeyPrinter
, (PRINTER_INFO_4A
*)pi
, buf
,
1100 if(pi
) pi
+= sizeof(PRINTER_INFO_4A
);
1103 WINSPOOL_GetPrinter_5A(hkeyPrinter
, (PRINTER_INFO_5A
*)pi
, buf
,
1106 if(pi
) pi
+= sizeof(PRINTER_INFO_5A
);
1109 ERR("Shouldn't be here!\n");
1110 RegCloseKey(hkeyPrinter
);
1111 RegCloseKey(hkeyPrinters
);
1114 RegCloseKey(hkeyPrinter
);
1116 RegCloseKey(hkeyPrinters
);
1122 memset(lpbPrinters
, 0, cbBuf
);
1123 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1127 *lpdwReturned
= number
;
1128 SetLastError(ERROR_SUCCESS
);
1132 /******************************************************************
1133 * EnumPrintersW [WINSPOOL.175]
1136 BOOL WINAPI
EnumPrintersW(DWORD dwType
, LPWSTR lpszName
,
1137 DWORD dwLevel
, LPBYTE lpbPrinters
,
1138 DWORD cbBuf
, LPDWORD lpdwNeeded
,
1139 LPDWORD lpdwReturned
)
1141 FIXME("Nearly empty stub\n");
1148 /*****************************************************************************
1149 * GetPrinterDriver32A [WINSPOOL.190]
1151 BOOL WINAPI
GetPrinterDriverA(HANDLE hPrinter
, LPSTR pEnvironment
,
1152 DWORD Level
, LPBYTE pDriverInfo
,
1153 DWORD cbBuf
, LPDWORD pcbNeeded
)
1155 OPENEDPRINTERA
*lpOpenedPrinter
;
1156 char DriverName
[100];
1157 DWORD ret
, type
, size
, dw
, needed
= 0;
1159 HKEY hkeyPrinter
, hkeyPrinters
, hkeyDriver
, hkeyDrivers
;
1161 TRACE("(%d,%s,%ld,%p,%ld,%p)\n",hPrinter
,pEnvironment
,
1162 Level
,pDriverInfo
,cbBuf
, pcbNeeded
);
1164 lpOpenedPrinter
= WINSPOOL_GetOpenedPrinterA(hPrinter
);
1165 if(!lpOpenedPrinter
) {
1166 SetLastError(ERROR_INVALID_HANDLE
);
1170 FIXME("pEnvironment = `%s'\n", pEnvironment
);
1171 SetLastError(ERROR_INVALID_ENVIRONMENT
);
1174 if(Level
< 1 || Level
> 3) {
1175 SetLastError(ERROR_INVALID_LEVEL
);
1178 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Printers
, &hkeyPrinters
) !=
1180 ERR("Can't create Printers key\n");
1183 if(RegOpenKeyA(hkeyPrinters
, lpOpenedPrinter
->lpsPrinterName
, &hkeyPrinter
)
1185 ERR("Can't find opened printer `%s' in registry\n",
1186 lpOpenedPrinter
->lpsPrinterName
);
1187 RegCloseKey(hkeyPrinters
);
1188 SetLastError(ERROR_INVALID_PRINTER_NAME
); /* ? */
1191 size
= sizeof(DriverName
);
1192 ret
= RegQueryValueExA(hkeyPrinter
, "Printer Driver", 0, &type
, DriverName
,
1194 RegCloseKey(hkeyPrinter
);
1195 RegCloseKey(hkeyPrinters
);
1196 if(ret
!= ERROR_SUCCESS
) {
1197 ERR("Can't get DriverName for printer `%s'\n",
1198 lpOpenedPrinter
->lpsPrinterName
);
1201 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Drivers
, &hkeyDrivers
) !=
1203 ERR("Can't create Drivers key\n");
1206 if(RegOpenKeyA(hkeyDrivers
, DriverName
, &hkeyDriver
)
1208 ERR("Can't find driver `%s' in registry\n", DriverName
);
1209 RegCloseKey(hkeyDrivers
);
1210 SetLastError(ERROR_UNKNOWN_PRINTER_DRIVER
); /* ? */
1216 size
= sizeof(DRIVER_INFO_1A
);
1219 size
= sizeof(DRIVER_INFO_2A
);
1222 size
= sizeof(DRIVER_INFO_3A
);
1225 ERR("Invalid level\n");
1230 ptr
= pDriverInfo
+ size
;
1236 size
= strlen(DriverName
) + 1;
1239 strcpy(ptr
, DriverName
);
1241 ((DRIVER_INFO_1A
*)pDriverInfo
)->pName
= ptr
;
1243 ((DRIVER_INFO_2A
*)pDriverInfo
)->pName
= ptr
;
1249 DRIVER_INFO_2A
*di2
= (DRIVER_INFO_2A
*)pDriverInfo
;
1252 if(RegQueryValueExA(hkeyDriver
, "Version", 0, &type
, (PBYTE
)&dw
,
1255 WARN("Can't get Version\n");
1259 size
= strlen("Wine") + 1; /* FIXME */
1262 strcpy(ptr
, "Wine");
1263 di2
->pEnvironment
= ptr
;
1269 WINSPOOL_GetStringFromRegA(hkeyDriver
, "Driver", ptr
, cbBuf
, &size
);
1270 if(cbBuf
&& size
<= cbBuf
) {
1271 di2
->pDriverPath
= ptr
;
1277 WINSPOOL_GetStringFromRegA(hkeyDriver
, "Data File", ptr
, cbBuf
, &size
);
1278 if(cbBuf
&& size
<= cbBuf
) {
1279 di2
->pDataFile
= ptr
;
1285 WINSPOOL_GetStringFromRegA(hkeyDriver
, "Configuration File", ptr
,
1287 if(cbBuf
&& size
<= cbBuf
) {
1288 di2
->pConfigFile
= ptr
;
1296 DRIVER_INFO_3A
*di3
= (DRIVER_INFO_3A
*)pDriverInfo
;
1298 WINSPOOL_GetStringFromRegA(hkeyDriver
, "Help File", ptr
, cbBuf
, &size
);
1299 if(cbBuf
&& size
<= cbBuf
) {
1300 di3
->pHelpFile
= ptr
;
1306 WINSPOOL_GetStringFromRegA(hkeyDriver
, "Dependent Files", ptr
, cbBuf
,
1308 if(cbBuf
&& size
<= cbBuf
) {
1309 di3
->pDependentFiles
= ptr
;
1315 WINSPOOL_GetStringFromRegA(hkeyDriver
, "Monitor", ptr
, cbBuf
, &size
);
1316 if(cbBuf
&& size
<= cbBuf
) {
1317 di3
->pMonitorName
= ptr
;
1323 WINSPOOL_GetStringFromRegA(hkeyDriver
, "DataType", ptr
, cbBuf
, &size
);
1324 if(cbBuf
&& size
<= cbBuf
) {
1325 di3
->pDefaultDataType
= ptr
;
1331 RegCloseKey(hkeyDriver
);
1332 RegCloseKey(hkeyDrivers
);
1334 if(pcbNeeded
) *pcbNeeded
= needed
;
1335 if(cbBuf
) return TRUE
;
1336 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1340 /*****************************************************************************
1341 * GetPrinterDriver32W [WINSPOOL.193]
1343 BOOL WINAPI
GetPrinterDriverW(HANDLE hPrinter
, LPWSTR pEnvironment
,
1344 DWORD Level
, LPBYTE pDriverInfo
,
1345 DWORD cbBuf
, LPDWORD pcbNeeded
)
1347 FIXME("(%d,%p,%ld,%p,%ld,%p): stub\n",hPrinter
,pEnvironment
,
1348 Level
,pDriverInfo
,cbBuf
, pcbNeeded
);
1352 /*****************************************************************************
1353 * GetPrinterDriverDirectoryA [WINSPOOL.191]
1355 BOOL WINAPI
GetPrinterDriverDirectoryA(LPSTR pName
, LPSTR pEnvironment
,
1356 DWORD Level
, LPBYTE pDriverDirectory
,
1357 DWORD cbBuf
, LPDWORD pcbNeeded
)
1361 TRACE("(%s, %s, %ld, %p, %ld, %p)\n", pName
, pEnvironment
, Level
,
1362 pDriverDirectory
, cbBuf
, pcbNeeded
);
1364 FIXME("pName = `%s' - unsupported\n", pName
);
1365 SetLastError(ERROR_INVALID_PARAMETER
);
1368 if(pEnvironment
!= NULL
) {
1369 FIXME("pEnvironment = `%s' - unsupported\n", pEnvironment
);
1370 SetLastError(ERROR_INVALID_ENVIRONMENT
);
1373 if(Level
!= 1) /* win95 ignores this so we just carry on */
1374 WARN("Level = %ld - assuming 1\n", Level
);
1376 /* FIXME should read from registry */
1377 needed
= GetSystemDirectoryA(pDriverDirectory
, cbBuf
);
1380 *pcbNeeded
= needed
;
1381 if(needed
> cbBuf
) {
1382 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1389 /*****************************************************************************
1390 * GetPrinterDriverDirectoryW [WINSPOOL.192]
1392 BOOL WINAPI
GetPrinterDriverDirectoryW(LPWSTR pName
, LPWSTR pEnvironment
,
1393 DWORD Level
, LPBYTE pDriverDirectory
,
1394 DWORD cbBuf
, LPDWORD pcbNeeded
)
1396 LPSTR pNameA
= NULL
, pEnvironmentA
= NULL
;
1400 pNameA
= HEAP_strdupWtoA( GetProcessHeap(), 0, pName
);
1402 pEnvironmentA
= HEAP_strdupWtoA( GetProcessHeap(), 0, pEnvironment
);
1403 ret
= GetPrinterDriverDirectoryA( pNameA
, pEnvironmentA
, Level
,
1404 pDriverDirectory
, cbBuf
, pcbNeeded
);
1406 HeapFree( GetProcessHeap(), 0, pNameA
);
1408 HeapFree( GetProcessHeap(), 0, pEnvironment
);
1413 /*****************************************************************************
1414 * AddPrinterDriver32A [WINSPOOL.120]
1416 BOOL WINAPI
AddPrinterDriverA(LPSTR pName
, DWORD level
, LPBYTE pDriverInfo
)
1419 HKEY hkeyDrivers
, hkeyName
;
1421 TRACE("(%s,%ld,%p)\n",pName
,level
,pDriverInfo
);
1423 if(level
!= 2 && level
!= 3) {
1424 SetLastError(ERROR_INVALID_LEVEL
);
1428 FIXME("pName= `%s' - unsupported\n", pName
);
1429 SetLastError(ERROR_INVALID_PARAMETER
);
1433 WARN("pDriverInfo == NULL");
1434 SetLastError(ERROR_INVALID_PARAMETER
);
1439 di3
= *(DRIVER_INFO_3A
*)pDriverInfo
;
1441 memset(&di3
, 0, sizeof(di3
));
1442 *(DRIVER_INFO_2A
*)&di3
= *(DRIVER_INFO_2A
*)pDriverInfo
;
1445 if(!di3
.pName
|| !di3
.pDriverPath
|| !di3
.pConfigFile
||
1447 SetLastError(ERROR_INVALID_PARAMETER
);
1450 if(!di3
.pDefaultDataType
) di3
.pDefaultDataType
= "";
1451 if(!di3
.pDependentFiles
) di3
.pDependentFiles
= "\0";
1452 if(!di3
.pHelpFile
) di3
.pHelpFile
= "";
1453 if(!di3
.pMonitorName
) di3
.pMonitorName
= "";
1455 if(di3
.pEnvironment
) {
1456 FIXME("pEnvironment = `%s'\n", di3
.pEnvironment
);
1457 SetLastError(ERROR_INVALID_ENVIRONMENT
);
1460 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Drivers
, &hkeyDrivers
) !=
1462 ERR("Can't create Drivers key\n");
1466 if(level
== 2) { /* apparently can't overwrite with level2 */
1467 if(RegOpenKeyA(hkeyDrivers
, di3
.pName
, &hkeyName
) == ERROR_SUCCESS
) {
1468 RegCloseKey(hkeyName
);
1469 RegCloseKey(hkeyDrivers
);
1470 WARN("Trying to create existing printer driver `%s'\n", di3
.pName
);
1471 SetLastError(ERROR_PRINTER_DRIVER_ALREADY_INSTALLED
);
1475 if(RegCreateKeyA(hkeyDrivers
, di3
.pName
, &hkeyName
) != ERROR_SUCCESS
) {
1476 RegCloseKey(hkeyDrivers
);
1477 ERR("Can't create Name key\n");
1480 RegSetValueExA(hkeyName
, "Configuration File", 0, REG_SZ
, di3
.pConfigFile
,
1482 RegSetValueExA(hkeyName
, "Data File", 0, REG_SZ
, di3
.pDataFile
, 0);
1483 RegSetValueExA(hkeyName
, "Driver", 0, REG_SZ
, di3
.pDriverPath
, 0);
1484 RegSetValueExA(hkeyName
, "Version", 0, REG_DWORD
, (LPSTR
)&di3
.cVersion
,
1486 RegSetValueExA(hkeyName
, "Datatype", 0, REG_SZ
, di3
.pDefaultDataType
, 0);
1487 RegSetValueExA(hkeyName
, "Dependent Files", 0, REG_MULTI_SZ
,
1488 di3
.pDependentFiles
, 0);
1489 RegSetValueExA(hkeyName
, "Help File", 0, REG_SZ
, di3
.pHelpFile
, 0);
1490 RegSetValueExA(hkeyName
, "Monitor", 0, REG_SZ
, di3
.pMonitorName
, 0);
1491 RegCloseKey(hkeyName
);
1492 RegCloseKey(hkeyDrivers
);
1496 /*****************************************************************************
1497 * AddPrinterDriver32W [WINSPOOL.121]
1499 BOOL WINAPI
AddPrinterDriverW(LPWSTR printerName
,DWORD level
,
1502 FIXME("(%s,%ld,%p): stub\n",debugstr_w(printerName
),
1508 /*****************************************************************************
1509 * PrinterProperties [WINSPOOL.201]
1511 * Displays a dialog to set the properties of the printer.
1514 * nonzero on succes or zero on faillure
1517 * implemented as stub only
1519 BOOL WINAPI
PrinterProperties(HWND hWnd
, /* handle to parent window */
1520 HANDLE hPrinter
/* handle to printer object */
1522 FIXME("(%d,%d): stub\n", hWnd
, hPrinter
);
1523 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1527 /*****************************************************************************
1528 * EnumJobsA [WINSPOOL.162]
1531 BOOL WINAPI
EnumJobsA(HANDLE hPrinter
, DWORD FirstJob
, DWORD NoJobs
,
1532 DWORD Level
, LPBYTE pJob
, DWORD cbBuf
, LPDWORD pcbNeeded
,
1536 if(pcbNeeded
) *pcbNeeded
= 0;
1537 if(pcReturned
) *pcReturned
= 0;
1542 /*****************************************************************************
1543 * EnumJobsW [WINSPOOL.163]
1546 BOOL WINAPI
EnumJobsW(HANDLE hPrinter
, DWORD FirstJob
, DWORD NoJobs
,
1547 DWORD Level
, LPBYTE pJob
, DWORD cbBuf
, LPDWORD pcbNeeded
,
1551 if(pcbNeeded
) *pcbNeeded
= 0;
1552 if(pcReturned
) *pcReturned
= 0;