4 * Copyright 1996 John Harvey
5 * Copyright 1998 Andreas Mohr
6 * Copyright 1999 Klaas van Gend
16 #include "debugtools.h"
19 DEFAULT_DEBUG_CHANNEL(winspool
)
21 CRITICAL_SECTION PRINT32_RegistryBlocker
;
23 #define NUM_PRINTER_MAX 10
25 typedef struct _OPENEDPRINTERA
29 LPPRINTER_DEFAULTSA lpDefault
;
30 } OPENEDPRINTERA
, *LPOPENEDPRINTERA
;
33 /* Initialize the structure OpenedPrinter Table */
34 static OPENEDPRINTERA OpenedPrinterTableA
[NUM_PRINTER_MAX
] =
48 static char Printers
[] =
49 "System\\CurrentControlSet\\control\\Print\\Printers\\";
50 static char Drivers
[] =
51 "System\\CurrentControlSet\\control\\Print\\Environments\\Wine\\Drivers\\";
54 /******************************************************************
55 * WINSPOOL_GetOpenedPrinterEntryA
56 * Get the first place empty in the opened printer table
58 static LPOPENEDPRINTERA
WINSPOOL_GetOpenedPrinterEntryA()
61 for( i
=0; i
< NUM_PRINTER_MAX
; i
++)
62 if (OpenedPrinterTableA
[i
].hPrinter
== -1)
64 OpenedPrinterTableA
[i
].hPrinter
= i
+ 1;
65 return &OpenedPrinterTableA
[i
];
70 /******************************************************************
71 * WINSPOOL_GetOpenedPrinterA
72 * Get the pointer to the opened printer referred by the handle
74 static LPOPENEDPRINTERA
WINSPOOL_GetOpenedPrinterA(int printerHandle
)
76 if((printerHandle
<=0) || (printerHandle
> (NUM_PRINTER_MAX
+ 1)))
78 return &OpenedPrinterTableA
[printerHandle
-1];
81 /******************************************************************
82 * DeviceCapabilities32A [WINSPOOL.151]
85 INT WINAPI
DeviceCapabilitiesA(LPCSTR pDeivce
,LPCSTR pPort
, WORD cap
,
86 LPSTR pOutput
, LPDEVMODEA lpdm
)
88 return GDI_CallDeviceCapabilities16(pDeivce
, pPort
, cap
, pOutput
, lpdm
);
93 /*****************************************************************************
94 * DeviceCapabilities32W
96 INT WINAPI
DeviceCapabilitiesW(LPCWSTR pDevice
, LPCWSTR pPort
,
97 WORD fwCapability
, LPWSTR pOutput
,
98 const DEVMODEW
*pDevMode
)
100 FIXME("(%p,%p,%d,%p,%p): stub\n",
101 pDevice
, pPort
, fwCapability
, pOutput
, pDevMode
);
105 /******************************************************************
106 * DocumentProperties32A [WINSPOOL.155]
109 LONG WINAPI
DocumentPropertiesA(HWND hWnd
,HANDLE hPrinter
,
110 LPSTR pDeviceName
, LPDEVMODEA pDevModeOutput
,
111 LPDEVMODEA pDevModeInput
,DWORD fMode
)
113 LPOPENEDPRINTERA lpOpenedPrinter
;
114 LPSTR lpName
= pDeviceName
;
116 TRACE("(%d,%d,%s,%p,%p,%ld)\n",
117 hWnd
,hPrinter
,pDeviceName
,pDevModeOutput
,pDevModeInput
,fMode
121 lpOpenedPrinter
= WINSPOOL_GetOpenedPrinterA(hPrinter
);
122 if(!lpOpenedPrinter
) {
123 SetLastError(ERROR_INVALID_HANDLE
);
126 lpName
= lpOpenedPrinter
->lpsPrinterName
;
129 return GDI_CallExtDeviceMode16(hWnd
, pDevModeOutput
, lpName
, NULL
,
130 pDevModeInput
, NULL
, fMode
);
135 /*****************************************************************************
136 * DocumentProperties32W
138 LONG WINAPI
DocumentPropertiesW(HWND hWnd
, HANDLE hPrinter
,
140 LPDEVMODEW pDevModeOutput
,
141 LPDEVMODEW pDevModeInput
, DWORD fMode
)
143 FIXME("(%d,%d,%s,%p,%p,%ld): stub\n",
144 hWnd
,hPrinter
,debugstr_w(pDeviceName
),pDevModeOutput
,pDevModeInput
,
150 /******************************************************************
151 * OpenPrinter32A [WINSPOOL.196]
154 BOOL WINAPI
OpenPrinterA(LPSTR lpPrinterName
,HANDLE
*phPrinter
,
155 LPPRINTER_DEFAULTSA pDefault
)
157 /* Not implemented: use the DesiredAccess of pDefault to set
158 the access rights to the printer */
160 LPOPENEDPRINTERA lpOpenedPrinter
;
162 TRACE("(printerName: %s, pDefault %p\n", lpPrinterName
, pDefault
);
164 /* Get a place in the opened printer buffer*/
165 lpOpenedPrinter
= WINSPOOL_GetOpenedPrinterEntryA();
167 if((lpOpenedPrinter
!= NULL
) && (lpPrinterName
!=NULL
) &&
170 /* Get the name of the printer */
171 lpOpenedPrinter
->lpsPrinterName
=
172 HeapAlloc(GetProcessHeap(), 0, lstrlenA(lpPrinterName
));
173 lstrcpyA(lpOpenedPrinter
->lpsPrinterName
, lpPrinterName
);
175 /* Get the unique handle of the printer*/
176 *phPrinter
= lpOpenedPrinter
->hPrinter
;
178 if (pDefault
!= NULL
)
180 /* Allocate enough memory for the lpDefault structure */
181 lpOpenedPrinter
->lpDefault
=
182 HeapAlloc(GetProcessHeap(), 0, sizeof(PRINTER_DEFAULTSA
));
183 lpOpenedPrinter
->lpDefault
->pDevMode
=
184 HeapAlloc(GetProcessHeap(), 0, sizeof(DEVMODEA
));
185 lpOpenedPrinter
->lpDefault
->pDatatype
=
186 HeapAlloc(GetProcessHeap(), 0, lstrlenA(pDefault
->pDatatype
));
188 /*Copy the information from incoming parameter*/
189 memcpy(lpOpenedPrinter
->lpDefault
->pDevMode
, pDefault
->pDevMode
,
191 lstrcpyA(lpOpenedPrinter
->lpDefault
->pDatatype
,
192 pDefault
->pDatatype
);
193 lpOpenedPrinter
->lpDefault
->DesiredAccess
=
194 pDefault
->DesiredAccess
;
200 if(lpOpenedPrinter
== NULL
)
201 FIXME("Reach the OpenedPrinterTable maximum, augment this max.\n");
205 /******************************************************************
206 * OpenPrinter32W [WINSPOOL.197]
209 BOOL WINAPI
OpenPrinterW(LPWSTR lpPrinterName
,HANDLE
*phPrinter
,
210 LPPRINTER_DEFAULTSW pDefault
)
212 FIXME("(%s,%p,%p):stub\n",debugstr_w(lpPrinterName
), phPrinter
,
214 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
221 /******************************************************************
222 * ENUMPRINTERS_GetDWORDFromRegistryA internal
224 * Reads a DWORD from registry KeyName
227 * value on OK or NULL on error
229 DWORD
ENUMPRINTERS_GetDWORDFromRegistryA(
230 HKEY hPrinterSettings
, /* handle to registry key */
231 LPSTR KeyName
/* name key to retrieve string from*/
238 if (RegQueryValueExA(hPrinterSettings
, KeyName
, NULL
, &DataType
,
239 Data
, &DataSize
)!=ERROR_SUCCESS
)
240 FIXME("Query of register didn't succeed?\n");
241 if (DataType
== REG_DWORD_LITTLE_ENDIAN
)
242 Result
= Data
[0] + (Data
[1]<<8) + (Data
[2]<<16) + (Data
[3]<<24);
243 if (DataType
== REG_DWORD_BIG_ENDIAN
)
244 Result
= Data
[3] + (Data
[2]<<8) + (Data
[1]<<16) + (Data
[0]<<24);
249 /******************************************************************
250 * ENUMPRINTERS_AddStringFromRegistryA internal
252 * Reads a string from registry KeyName and writes it at
253 * lpbPrinters[dwNextStringPos]. Store reference to string in Dest.
256 * FALSE if there is still space left in the buffer.
258 BOOL
ENUMPRINTERS_AddStringFromRegistryA(
259 HKEY hPrinterSettings
, /* handle to registry key */
260 LPSTR KeyName
, /* name key to retrieve string from*/
261 LPSTR
* Dest
, /* pointer to write string addres to */
262 LPBYTE lpbPrinters
, /* buffer which receives info*/
263 LPDWORD dwNextStringPos
, /* pos in buffer for next string */
264 DWORD dwBufSize
, /* max size of buffer in bytes */
265 BOOL bCalcSpaceOnly
/* TRUE if out-of-space in buffer */
269 LPSTR Data
= (LPSTR
) malloc(DataSize
*sizeof(char));
271 while(RegQueryValueExA(hPrinterSettings
, KeyName
, NULL
, &DataType
,
272 Data
, &DataSize
)==ERROR_MORE_DATA
)
274 Data
= (LPSTR
) realloc(Data
, DataSize
+2);
277 if (DataType
== REG_SZ
)
279 if (bCalcSpaceOnly
==FALSE
)
280 *Dest
= &lpbPrinters
[*dwNextStringPos
];
281 *dwNextStringPos
+= DataSize
+1;
282 if (*dwNextStringPos
> dwBufSize
)
284 if (bCalcSpaceOnly
==FALSE
)
286 if (DataSize
==0) /* DataSize = 0 means empty string, even though*/
287 *Dest
[0]=0; /* the data itself needs not to be empty */
293 WARN("Expected string setting, got something else from registry");
297 return(bCalcSpaceOnly
);
302 /******************************************************************
303 * ENUMPRINTERS_AddInfo2A internal
305 * Creates a PRINTER_INFO_2A structure at: lpbPrinters[dwNextStructPos]
306 * for printer PrinterNameKey.
307 * Note that there is no check whether the information really fits!
310 * FALSE if there is still space left in the buffer.
313 * This function should not only read the registry but also ask the driver
316 BOOL
ENUMPRINTERS_AddInfo2A(
317 LPSTR lpszPrinterName
,/* name of printer to fill struct for*/
318 LPBYTE lpbPrinters
, /* buffer which receives info*/
319 DWORD dwNextStructPos
, /* pos in buffer for struct */
320 LPDWORD dwNextStringPos
, /* pos in buffer for next string */
321 DWORD dwBufSize
, /* max size of buffer in bytes */
322 BOOL bCalcSpaceOnly
/* TRUE if out-of-space in buffer */
324 HKEY hPrinterSettings
;
327 LPSTR lpszPrinterSettings
= (LPSTR
) malloc(strlen(Printers
)+
328 strlen(lpszPrinterName
)+2);
329 LPPRINTER_INFO_2A lpPInfo2
= (LPPRINTER_INFO_2A
) &lpbPrinters
[dwNextStructPos
];
331 /* open the registry to find the attributes, etc of the printer */
332 if (lpszPrinterSettings
!=NULL
)
334 strcpy(lpszPrinterSettings
,Printers
);
335 strcat(lpszPrinterSettings
,lpszPrinterName
);
337 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
, lpszPrinterSettings
, 0,
338 KEY_READ
, &hPrinterSettings
) != ERROR_SUCCESS
)
340 WARN("The registry did not contain my printer anymore?\n");
344 if (bCalcSpaceOnly
==FALSE
)
345 lpPInfo2
->pServerName
= NULL
;
346 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
347 "Name", &(lpPInfo2
->pPrinterName
),
348 lpbPrinters
, dwNextStringPos
,
349 dwBufSize
, bCalcSpaceOnly
);
350 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
351 "Share Name", &(lpPInfo2
->pShareName
),
352 lpbPrinters
, dwNextStringPos
,
353 dwBufSize
, bCalcSpaceOnly
);
354 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
355 "Port", &(lpPInfo2
->pPortName
),
356 lpbPrinters
, dwNextStringPos
,
357 dwBufSize
, bCalcSpaceOnly
);
358 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
359 "Printer Driver", &(lpPInfo2
->pDriverName
),
360 lpbPrinters
, dwNextStringPos
,
361 dwBufSize
, bCalcSpaceOnly
);
362 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
363 "Description", &(lpPInfo2
->pComment
),
364 lpbPrinters
, dwNextStringPos
,
365 dwBufSize
, bCalcSpaceOnly
);
366 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
367 "Location", &(lpPInfo2
->pLocation
),
368 lpbPrinters
, dwNextStringPos
,
369 dwBufSize
, bCalcSpaceOnly
);
371 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
372 "Separator File", &(lpPInfo2
->pSepFile
),
373 lpbPrinters
, dwNextStringPos
,
374 dwBufSize
, bCalcSpaceOnly
);
375 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
376 "Print Processor", &(lpPInfo2
->pPrintProcessor
),
377 lpbPrinters
, dwNextStringPos
,
378 dwBufSize
, bCalcSpaceOnly
);
379 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
380 "Datatype", &(lpPInfo2
->pDatatype
),
381 lpbPrinters
, dwNextStringPos
,
382 dwBufSize
, bCalcSpaceOnly
);
383 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
384 "Parameters", &(lpPInfo2
->pParameters
),
385 lpbPrinters
, dwNextStringPos
,
386 dwBufSize
, bCalcSpaceOnly
);
387 if (bCalcSpaceOnly
== FALSE
)
389 lpPInfo2
->pSecurityDescriptor
= NULL
; /* EnumPrinters doesn't return this*/
391 /* FIXME: Attributes gets LOCAL as no REMOTE exists*/
392 lpPInfo2
->Attributes
= ENUMPRINTERS_GetDWORDFromRegistryA(hPrinterSettings
,
393 "Attributes") +PRINTER_ATTRIBUTE_LOCAL
;
394 lpPInfo2
->Priority
= ENUMPRINTERS_GetDWORDFromRegistryA(hPrinterSettings
,
396 lpPInfo2
->DefaultPriority
= ENUMPRINTERS_GetDWORDFromRegistryA(
397 hPrinterSettings
, "Default Priority");
398 lpPInfo2
->StartTime
= ENUMPRINTERS_GetDWORDFromRegistryA(hPrinterSettings
,
400 lpPInfo2
->UntilTime
= ENUMPRINTERS_GetDWORDFromRegistryA(hPrinterSettings
,
402 lpPInfo2
->Status
= ENUMPRINTERS_GetDWORDFromRegistryA(hPrinterSettings
,
404 lpPInfo2
->cJobs
= 0; /* FIXME: according to MSDN, this does not
405 * reflect the TotalJobs Key ??? */
406 lpPInfo2
->AveragePPM
= 0; /* FIXME: according to MSDN, this does not
407 * reflect the TotalPages Key ??? */
409 /* and read the devModes structure... */
410 RegQueryValueExA(hPrinterSettings
, "pDevMode", NULL
, &DataType
,
411 NULL
, &DevSize
); /* should return ERROR_MORE_DATA */
412 lpPInfo2
->pDevMode
= (LPDEVMODEA
) &lpbPrinters
[*dwNextStringPos
];
413 *dwNextStringPos
+= DevSize
+ 1;
415 if (*dwNextStringPos
> dwBufSize
)
417 if (bCalcSpaceOnly
==FALSE
)
418 RegQueryValueExA(hPrinterSettings
, "pDevMode", NULL
, &DataType
,
419 (LPBYTE
)lpPInfo2
->pDevMode
, &DevSize
);
422 if (lpszPrinterSettings
)
423 free(lpszPrinterSettings
);
425 return(bCalcSpaceOnly
);
428 /******************************************************************
429 * ENUMPRINTERS_AddInfo4A internal
431 * Creates a PRINTER_INFO_4A structure at: lpbPrinters[dwNextStructPos]
432 * for printer PrinterNameKey.
433 * Note that there is no check whether the information really fits!
436 * FALSE if there is still space left in the buffer.
439 * This function should not exist in Win95 mode, but does anyway.
441 BOOL
ENUMPRINTERS_AddInfo4A(
442 LPSTR lpszPrinterName
,/* name of printer to fill struct for*/
443 LPBYTE lpbPrinters
, /* buffer which receives info*/
444 DWORD dwNextStructPos
, /* pos in buffer for struct */
445 LPDWORD dwNextStringPos
, /* pos in buffer for next string */
446 DWORD dwBufSize
, /* max size of buffer in bytes */
447 BOOL bCalcSpaceOnly
/* TRUE if out-of-space in buffer */
449 HKEY hPrinterSettings
;
450 LPSTR lpszPrinterSettings
= (LPSTR
) malloc(strlen(Printers
)+
451 strlen(lpszPrinterName
)+2);
452 LPPRINTER_INFO_4A lpPInfo4
= (LPPRINTER_INFO_4A
) &lpbPrinters
[dwNextStructPos
];
454 /* open the registry to find the attributes of the printer */
455 if (lpszPrinterSettings
!=NULL
)
457 strcpy(lpszPrinterSettings
,Printers
);
458 strcat(lpszPrinterSettings
,lpszPrinterName
);
460 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
, lpszPrinterSettings
, 0,
461 KEY_READ
, &hPrinterSettings
) != ERROR_SUCCESS
)
463 WARN("The registry did not contain my printer anymore?\n");
467 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
468 "Name", &(lpPInfo4
->pPrinterName
),
469 lpbPrinters
, dwNextStringPos
,
470 dwBufSize
, bCalcSpaceOnly
);
471 /* FIXME: Attributes gets LOCAL as no REMOTE exists*/
472 if (bCalcSpaceOnly
==FALSE
)
473 lpPInfo4
->Attributes
= ENUMPRINTERS_GetDWORDFromRegistryA(hPrinterSettings
,
474 "Attributes") +PRINTER_ATTRIBUTE_LOCAL
;
476 if (lpszPrinterSettings
)
477 free(lpszPrinterSettings
);
479 return(bCalcSpaceOnly
);
482 /******************************************************************
483 * ENUMPRINTERS_AddInfo5A internal
485 * Creates a PRINTER_INFO_5A structure at: lpbPrinters[dwNextStructPos]
486 * for printer PrinterNameKey.
487 * Settings are read from the registry.
488 * Note that there is no check whether the information really fits!
490 * FALSE if there is still space left in the buffer.
492 BOOL
ENUMPRINTERS_AddInfo5A(
493 LPSTR lpszPrinterName
,/* name of printer to fill struct for*/
494 LPBYTE lpbPrinters
, /* buffer which receives info*/
495 DWORD dwNextStructPos
, /* pos in buffer for struct */
496 LPDWORD dwNextStringPos
, /* pos in buffer for next string */
497 DWORD dwBufSize
, /* max size of buffer in bytes */
498 BOOL bCalcSpaceOnly
/* TRUE if out-of-space in buffer */
500 HKEY hPrinterSettings
;
501 LPSTR lpszPrinterSettings
= (LPSTR
) malloc(strlen(Printers
)+
502 strlen(lpszPrinterName
)+2);
503 LPPRINTER_INFO_5A lpPInfo5
= (LPPRINTER_INFO_5A
) &lpbPrinters
[dwNextStructPos
];
505 /* open the registry to find the attributes, etc of the printer */
506 if (lpszPrinterSettings
!=NULL
)
508 strcpy(lpszPrinterSettings
,Printers
);
509 strcat(lpszPrinterSettings
,lpszPrinterName
);
511 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
, lpszPrinterSettings
, 0,
512 KEY_READ
, &hPrinterSettings
) != ERROR_SUCCESS
)
514 WARN("The registry did not contain my printer anymore?\n");
518 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
519 "Name", &(lpPInfo5
->pPrinterName
),
520 lpbPrinters
, dwNextStringPos
,
521 dwBufSize
, bCalcSpaceOnly
);
522 bCalcSpaceOnly
= ENUMPRINTERS_AddStringFromRegistryA(hPrinterSettings
,
523 "Port", &(lpPInfo5
->pPortName
), lpbPrinters
,
524 dwNextStringPos
, dwBufSize
, bCalcSpaceOnly
);
525 /* FIXME: Attributes gets LOCAL as no REMOTE exists*/
526 if (bCalcSpaceOnly
== FALSE
)
528 lpPInfo5
->Attributes
= ENUMPRINTERS_GetDWORDFromRegistryA(hPrinterSettings
,
529 "Attributes") +PRINTER_ATTRIBUTE_LOCAL
;
530 lpPInfo5
->DeviceNotSelectedTimeOut
531 = ENUMPRINTERS_GetDWORDFromRegistryA(hPrinterSettings
,
533 lpPInfo5
->TransmissionRetryTimeout
534 = ENUMPRINTERS_GetDWORDFromRegistryA(hPrinterSettings
,
539 if (lpszPrinterSettings
)
540 free(lpszPrinterSettings
);
542 return(bCalcSpaceOnly
);
546 /******************************************************************
547 * EnumPrintersA [WINSPOOL.174]
549 * Enumerates the available printers, print servers and print
550 * providers, depending on the specified flags, name and level.
554 * If level is set to 1:
555 * Not implemented yet!
556 * Returns TRUE with an empty list.
558 * If level is set to 2:
559 * Possible flags: PRINTER_ENUM_CONNECTIONS, PRINTER_ENUM_LOCAL.
560 * Returns an array of PRINTER_INFO_2 data structures in the
561 * lpbPrinters buffer. Note that according to MSDN also an
562 * OpenPrinter should be performed on every remote printer.
564 * If level is set to 4 (officially WinNT only):
565 * Possible flags: PRINTER_ENUM_CONNECTIONS, PRINTER_ENUM_LOCAL.
566 * Fast: Only the registry is queried to retrieve printer names,
567 * no connection to the driver is made.
568 * Returns an array of PRINTER_INFO_4 data structures in the
569 * lpbPrinters buffer.
571 * If level is set to 5 (officially WinNT4/Win9x only):
572 * Fast: Only the registry is queried to retrieve printer names,
573 * no connection to the driver is made.
574 * Returns an array of PRINTER_INFO_5 data structures in the
575 * lpbPrinters buffer.
577 * If level set to 3 or 6+:
578 * returns zero (faillure!)
580 * Returns nonzero (TRUE) on succes, or zero on faillure, use GetLastError
584 * - Only PRINTER_ENUM_LOCAL and PRINTER_ENUM_NAME are implemented.
585 * - Only levels 2, 4 and 5 are implemented at the moment.
586 * - 16-bit printer drivers are not enumerated.
587 * - Returned amount of bytes used/needed does not match the real Windoze
588 * implementation (as in this implementation, all strings are part
589 * of the buffer, whereas Win32 keeps them somewhere else)
590 * - At level 2, EnumPrinters should also call OpenPrinter for remote printers.
593 * - In a regular Wine installation, no registry settings for printers
594 * exist, which makes this function return an empty list.
596 BOOL WINAPI
EnumPrintersA(
597 DWORD dwType
, /* Types of print objects to enumerate */
598 LPSTR lpszName
, /* name of objects to enumerate */
599 DWORD dwLevel
, /* type of printer info structure */
600 LPBYTE lpbPrinters
,/* buffer which receives info*/
601 DWORD cbBuf
, /* max size of buffer in bytes */
602 LPDWORD lpdwNeeded
,/* pointer to var: # bytes used/needed */
603 LPDWORD lpdwReturned
/* number of entries returned */
606 HKEY hPrinterListKey
;
608 char PrinterName
[255];
609 DWORD PrinterNameLength
=255;
611 DWORD dwNextStringPos
; /* position of next space for a string in the buffer*/
612 DWORD dwStructPrinterInfoSize
; /* size of a Printer_Info_X structure */
613 BOOL bCalcSpaceOnly
=FALSE
;/* if TRUE: don't store data, just calculate space*/
617 /* test whether we're requested to really fill in. If so,
618 * zero out the data area, and initialise some returns to zero,
619 * to prevent problems
621 if (lpbPrinters
==NULL
|| cbBuf
==0)
626 for (i
=0; i
<cbBuf
; i
++)
632 /* check for valid Flags */
633 if (dwType
!= PRINTER_ENUM_LOCAL
&& dwType
!= PRINTER_ENUM_NAME
)
635 SetLastError(ERROR_INVALID_FLAGS
);
647 SetLastError(ERROR_INVALID_PARAMETER
);
651 /* Enter critical section to prevent AddPrinters() et al. to
652 * modify whilst we're reading in the registry
654 InitializeCriticalSection(&PRINT32_RegistryBlocker
);
655 EnterCriticalSection(&PRINT32_RegistryBlocker
);
657 /* get a pointer to a list of all printer names in the registry */
658 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
, Printers
, 0, KEY_READ
,
659 &hPrinterListKey
) !=ERROR_SUCCESS
)
661 /* Oh no! An empty list of printers!
662 * (which is a valid configuration anyway)
664 TRACE("No entries in the Printers part of the registry\n");
667 /* count the number of entries and check if it fits in the buffer
669 while(RegEnumKeyExA(hPrinterListKey
, dwIndex
, PrinterName
, &PrinterNameLength
,
670 NULL
, NULL
, NULL
, &FileTime
)==ERROR_SUCCESS
)
672 PrinterNameLength
=255;
675 *lpdwReturned
= dwIndex
;
679 dwStructPrinterInfoSize
= sizeof(PRINTER_INFO_1A
);
682 dwStructPrinterInfoSize
= sizeof(PRINTER_INFO_2A
);
685 dwStructPrinterInfoSize
= sizeof(PRINTER_INFO_4A
);
688 dwStructPrinterInfoSize
= sizeof(PRINTER_INFO_5A
);
691 dwStructPrinterInfoSize
= 0;
694 if (dwIndex
*dwStructPrinterInfoSize
+1 > cbBuf
)
695 bCalcSpaceOnly
= TRUE
;
697 /* the strings which contain e.g. PrinterName, PortName, etc,
698 * are also stored in lpbPrinters, but after the regular structs.
699 * dwNextStringPos will always point to the next free place for a
702 dwNextStringPos
=(dwIndex
+1)*dwStructPrinterInfoSize
;
704 /* check each entry: if OK, add to list in corresponding INFO .
706 for(dwIndex
=0; dwIndex
< *lpdwReturned
; dwIndex
++)
708 PrinterNameLength
=255;
709 if (RegEnumKeyExA(hPrinterListKey
, dwIndex
, PrinterName
, &PrinterNameLength
,
710 NULL
, NULL
, NULL
, &FileTime
)!=ERROR_SUCCESS
)
711 break; /* exit for loop*/
713 /* check whether this printer is allowed in the list
714 * by comparing name to lpszName
716 if (dwType
== PRINTER_ENUM_NAME
)
717 if (strcmp(PrinterName
,lpszName
)!=0)
723 /* FIXME: unimplemented */
726 bCalcSpaceOnly
= ENUMPRINTERS_AddInfo2A(PrinterName
, lpbPrinters
,
727 dwIndex
*dwStructPrinterInfoSize
,
728 &dwNextStringPos
, cbBuf
, bCalcSpaceOnly
);
731 bCalcSpaceOnly
= ENUMPRINTERS_AddInfo4A(PrinterName
, lpbPrinters
,
732 dwIndex
*dwStructPrinterInfoSize
,
733 &dwNextStringPos
, cbBuf
, bCalcSpaceOnly
);
736 bCalcSpaceOnly
= ENUMPRINTERS_AddInfo5A(PrinterName
, lpbPrinters
,
737 dwIndex
*dwStructPrinterInfoSize
,
738 &dwNextStringPos
, cbBuf
, bCalcSpaceOnly
);
742 RegCloseKey(hPrinterListKey
);
743 *lpdwNeeded
= dwNextStringPos
;
745 if (bCalcSpaceOnly
==TRUE
)
747 if (lpbPrinters
!=NULL
)
750 for (i
=0; i
<cbBuf
; i
++)
755 LeaveCriticalSection(&PRINT32_RegistryBlocker
);
759 /******************************************************************
760 * EnumPrinters32W [WINSPOOL.175]
763 BOOL WINAPI
EnumPrintersW(DWORD dwType
, LPWSTR lpszName
,
764 DWORD dwLevel
, LPBYTE lpbPrinters
,
765 DWORD cbBuf
, LPDWORD lpdwNeeded
,
766 LPDWORD lpdwReturned
)
768 FIXME("Nearly empty stub\n");
774 /******************************************************************
775 * AddMonitor32A [WINSPOOL.107]
778 BOOL WINAPI
AddMonitorA(LPCSTR pName
, DWORD Level
, LPBYTE pMonitors
)
780 FIXME("(%s,%lx,%p):stub!\n", pName
, Level
, pMonitors
);
781 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
785 /******************************************************************
786 * DeletePrinterDriver32A [WINSPOOL.146]
790 DeletePrinterDriverA (LPSTR pName
, LPSTR pEnvironment
, LPSTR pDriverName
)
792 FIXME("(%s,%s,%s):stub\n",debugstr_a(pName
),debugstr_a(pEnvironment
),
793 debugstr_a(pDriverName
));
794 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
799 /******************************************************************
800 * DeleteMonitor32A [WINSPOOL.135]
804 DeleteMonitorA (LPSTR pName
, LPSTR pEnvironment
, LPSTR pMonitorName
)
806 FIXME("(%s,%s,%s):stub\n",debugstr_a(pName
),debugstr_a(pEnvironment
),
807 debugstr_a(pMonitorName
));
808 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
813 /******************************************************************
814 * DeletePort32A [WINSPOOL.137]
818 DeletePortA (LPSTR pName
, HWND hWnd
, LPSTR pPortName
)
820 FIXME("(%s,0x%08x,%s):stub\n",debugstr_a(pName
),hWnd
,
821 debugstr_a(pPortName
));
822 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
826 /******************************************************************************
827 * SetPrinter32W [WINSPOOL.214]
837 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
841 /******************************************************************************
842 * WritePrinter32 [WINSPOOL.223]
852 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
856 /*****************************************************************************
857 * AddForm32A [WINSPOOL.103]
859 BOOL WINAPI
AddFormA(HANDLE hPrinter
, DWORD Level
, LPBYTE pForm
)
861 FIXME("(%d,%ld,%p): stub\n", hPrinter
, Level
, pForm
);
865 /*****************************************************************************
866 * AddForm32W [WINSPOOL.104]
868 BOOL WINAPI
AddFormW(HANDLE hPrinter
, DWORD Level
, LPBYTE pForm
)
870 FIXME("(%d,%ld,%p): stub\n", hPrinter
, Level
, pForm
);
874 /*****************************************************************************
875 * AddJob32A [WINSPOOL.105]
877 BOOL WINAPI
AddJobA(HANDLE hPrinter
, DWORD Level
, LPBYTE pData
,
878 DWORD cbBuf
, LPDWORD pcbNeeded
)
880 FIXME("(%d,%ld,%p,%ld,%p): stub\n", hPrinter
, Level
, pData
, cbBuf
,
885 /*****************************************************************************
886 * AddJob32W [WINSPOOL.106]
888 BOOL WINAPI
AddJobW(HANDLE hPrinter
, DWORD Level
, LPBYTE pData
, DWORD cbBuf
,
891 FIXME("(%d,%ld,%p,%ld,%p): stub\n", hPrinter
, Level
, pData
, cbBuf
,
896 /*****************************************************************************
897 * AddPrinter32A [WINSPOOL.117]
899 HANDLE WINAPI
AddPrinterA(LPSTR pName
, DWORD Level
, LPBYTE pPrinter
)
901 PRINTER_INFO_2A
*pi
= (PRINTER_INFO_2A
*) pPrinter
;
904 HKEY hkeyPrinter
, hkeyPrinters
, hkeyDriver
, hkeyDrivers
;
906 TRACE("(%s,%ld,%p)\n", pName
, Level
, pPrinter
);
909 FIXME("pName = `%s' - unsupported\n", pName
);
910 SetLastError(ERROR_INVALID_PARAMETER
);
914 WARN("Level = %ld\n", Level
);
915 SetLastError(ERROR_INVALID_LEVEL
);
919 SetLastError(ERROR_INVALID_PARAMETER
);
922 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Printers
, &hkeyPrinters
) !=
924 ERR("Can't create Printers key\n");
927 if(RegOpenKeyA(hkeyPrinters
, pi
->pPrinterName
, &hkeyPrinter
) ==
929 SetLastError(ERROR_PRINTER_ALREADY_EXISTS
);
930 RegCloseKey(hkeyPrinter
);
931 RegCloseKey(hkeyPrinters
);
934 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Drivers
, &hkeyDrivers
) !=
936 ERR("Can't create Drivers key\n");
937 RegCloseKey(hkeyPrinters
);
940 if(RegOpenKeyA(hkeyDrivers
, pi
->pDriverName
, &hkeyDriver
) !=
942 WARN("Can't find driver `%s'\n", pi
->pDriverName
);
943 RegCloseKey(hkeyPrinters
);
944 RegCloseKey(hkeyDrivers
);
945 SetLastError(ERROR_UNKNOWN_PRINTER_DRIVER
);
948 RegCloseKey(hkeyDriver
);
949 RegCloseKey(hkeyDrivers
);
950 if(strcasecmp(pi
->pPrintProcessor
, "WinPrint")) { /* FIXME */
951 WARN("Can't find processor `%s'\n", pi
->pPrintProcessor
);
952 SetLastError(ERROR_UNKNOWN_PRINTPROCESSOR
);
953 RegCloseKey(hkeyPrinters
);
956 if(RegCreateKeyA(hkeyPrinters
, pi
->pPrinterName
, &hkeyPrinter
) !=
958 WARN("Can't create printer `%s'\n", pi
->pPrinterName
);
959 SetLastError(ERROR_INVALID_PRINTER_NAME
);
960 RegCloseKey(hkeyPrinters
);
963 RegSetValueExA(hkeyPrinter
, "Attributes", 0, REG_DWORD
,
964 (LPSTR
)&pi
->Attributes
, sizeof(DWORD
));
965 RegSetValueExA(hkeyPrinter
, "Default DevMode", 0, REG_BINARY
,
966 (LPSTR
)&pi
->pDevMode
,
967 pi
->pDevMode
? pi
->pDevMode
->dmSize
: 0);
968 RegSetValueExA(hkeyPrinter
, "Description", 0, REG_SZ
, pi
->pComment
, 0);
969 RegSetValueExA(hkeyPrinter
, "Location", 0, REG_SZ
, pi
->pLocation
, 0);
970 RegSetValueExA(hkeyPrinter
, "Name", 0, REG_SZ
, pi
->pPrinterName
, 0);
971 RegSetValueExA(hkeyPrinter
, "Parameters", 0, REG_SZ
, pi
->pParameters
, 0);
972 RegSetValueExA(hkeyPrinter
, "Port", 0, REG_SZ
, pi
->pPortName
, 0);
973 RegSetValueExA(hkeyPrinter
, "Print Processor", 0, REG_SZ
,
974 pi
->pPrintProcessor
, 0);
975 RegSetValueExA(hkeyPrinter
, "Printer Driver", 0, REG_SZ
, pi
->pDriverName
,
977 RegSetValueExA(hkeyPrinter
, "Priority", 0, REG_DWORD
,
978 (LPSTR
)&pi
->Priority
, sizeof(DWORD
));
979 RegSetValueExA(hkeyPrinter
, "Separator File", 0, REG_SZ
, pi
->pSepFile
, 0);
980 RegSetValueExA(hkeyPrinter
, "Share Name", 0, REG_SZ
, pi
->pShareName
, 0);
981 RegSetValueExA(hkeyPrinter
, "Start Time", 0, REG_DWORD
,
982 (LPSTR
)&pi
->StartTime
, sizeof(DWORD
));
983 RegSetValueExA(hkeyPrinter
, "Status", 0, REG_DWORD
,
984 (LPSTR
)&pi
->Status
, sizeof(DWORD
));
985 RegSetValueExA(hkeyPrinter
, "Until Time", 0, REG_DWORD
,
986 (LPSTR
)&pi
->UntilTime
, sizeof(DWORD
));
988 RegCloseKey(hkeyPrinter
);
989 RegCloseKey(hkeyPrinters
);
990 if(!OpenPrinterA(pi
->pPrinterName
, &retval
, NULL
)) {
991 ERR("OpenPrinter failing\n");
997 /*****************************************************************************
998 * AddPrinter32W [WINSPOOL.122]
1000 HANDLE WINAPI
AddPrinterW(LPWSTR pName
, DWORD Level
, LPBYTE pPrinter
)
1002 FIXME("(%p,%ld,%p): stub\n", pName
, Level
, pPrinter
);
1007 /*****************************************************************************
1008 * ClosePrinter32 [WINSPOOL.126]
1010 BOOL WINAPI
ClosePrinter(HANDLE hPrinter
)
1012 LPOPENEDPRINTERA lpOpenedPrinter
;
1014 if ((hPrinter
!= -1) && (hPrinter
< NUM_PRINTER_MAX
+ 1))
1016 lpOpenedPrinter
= WINSPOOL_GetOpenedPrinterA(hPrinter
);
1017 HeapFree(GetProcessHeap(), 0, lpOpenedPrinter
->lpsPrinterName
);
1018 lpOpenedPrinter
->lpsPrinterName
= NULL
;
1020 /* Free the memory of lpDefault if it has been initialized*/
1021 if(lpOpenedPrinter
->lpDefault
!= NULL
)
1023 HeapFree(GetProcessHeap(), 0,
1024 lpOpenedPrinter
->lpDefault
->pDevMode
);
1025 HeapFree(GetProcessHeap(), 0,
1026 lpOpenedPrinter
->lpDefault
->pDatatype
);
1027 HeapFree(GetProcessHeap(), 0,
1028 lpOpenedPrinter
->lpDefault
);
1029 lpOpenedPrinter
->lpDefault
= NULL
;
1032 lpOpenedPrinter
->hPrinter
= -1;
1039 /*****************************************************************************
1040 * DeleteForm32A [WINSPOOL.133]
1042 BOOL WINAPI
DeleteFormA(HANDLE hPrinter
, LPSTR pFormName
)
1044 FIXME("(%d,%s): stub\n", hPrinter
, pFormName
);
1048 /*****************************************************************************
1049 * DeleteForm32W [WINSPOOL.134]
1051 BOOL WINAPI
DeleteFormW(HANDLE hPrinter
, LPWSTR pFormName
)
1053 FIXME("(%d,%s): stub\n", hPrinter
, debugstr_w(pFormName
));
1057 /*****************************************************************************
1058 * DeletePrinter32 [WINSPOOL.143]
1060 BOOL WINAPI
DeletePrinter(HANDLE hPrinter
)
1062 FIXME("(%d): stub\n", hPrinter
);
1066 /*****************************************************************************
1067 * SetPrinter32A [WINSPOOL.211]
1069 BOOL WINAPI
SetPrinterA(HANDLE hPrinter
, DWORD Level
, LPBYTE pPrinter
,
1072 FIXME("(%d,%ld,%p,%ld): stub\n",hPrinter
,Level
,pPrinter
,Command
);
1076 /*****************************************************************************
1077 * SetJob32A [WINSPOOL.209]
1079 BOOL WINAPI
SetJobA(HANDLE hPrinter
, DWORD JobId
, DWORD Level
,
1080 LPBYTE pJob
, DWORD Command
)
1082 FIXME("(%d,%ld,%ld,%p,%ld): stub\n",hPrinter
,JobId
,Level
,pJob
,
1087 /*****************************************************************************
1088 * SetJob32W [WINSPOOL.210]
1090 BOOL WINAPI
SetJobW(HANDLE hPrinter
, DWORD JobId
, DWORD Level
,
1091 LPBYTE pJob
, DWORD Command
)
1093 FIXME("(%d,%ld,%ld,%p,%ld): stub\n",hPrinter
,JobId
,Level
,pJob
,
1098 /*****************************************************************************
1099 * GetForm32A [WINSPOOL.181]
1101 BOOL WINAPI
GetFormA(HANDLE hPrinter
, LPSTR pFormName
, DWORD Level
,
1102 LPBYTE pForm
, DWORD cbBuf
, LPDWORD pcbNeeded
)
1104 FIXME("(%d,%s,%ld,%p,%ld,%p): stub\n",hPrinter
,pFormName
,
1105 Level
,pForm
,cbBuf
,pcbNeeded
);
1109 /*****************************************************************************
1110 * GetForm32W [WINSPOOL.182]
1112 BOOL WINAPI
GetFormW(HANDLE hPrinter
, LPWSTR pFormName
, DWORD Level
,
1113 LPBYTE pForm
, DWORD cbBuf
, LPDWORD pcbNeeded
)
1115 FIXME("(%d,%s,%ld,%p,%ld,%p): stub\n",hPrinter
,
1116 debugstr_w(pFormName
),Level
,pForm
,cbBuf
,pcbNeeded
);
1120 /*****************************************************************************
1121 * SetForm32A [WINSPOOL.207]
1123 BOOL WINAPI
SetFormA(HANDLE hPrinter
, LPSTR pFormName
, DWORD Level
,
1126 FIXME("(%d,%s,%ld,%p): stub\n",hPrinter
,pFormName
,Level
,pForm
);
1130 /*****************************************************************************
1131 * SetForm32W [WINSPOOL.208]
1133 BOOL WINAPI
SetFormW(HANDLE hPrinter
, LPWSTR pFormName
, DWORD Level
,
1136 FIXME("(%d,%p,%ld,%p): stub\n",hPrinter
,pFormName
,Level
,pForm
);
1140 /*****************************************************************************
1141 * ReadPrinter32 [WINSPOOL.202]
1143 BOOL WINAPI
ReadPrinter(HANDLE hPrinter
, LPVOID pBuf
, DWORD cbBuf
,
1144 LPDWORD pNoBytesRead
)
1146 FIXME("(%d,%p,%ld,%p): stub\n",hPrinter
,pBuf
,cbBuf
,pNoBytesRead
);
1150 /*****************************************************************************
1151 * ResetPrinter32A [WINSPOOL.203]
1153 BOOL WINAPI
ResetPrinterA(HANDLE hPrinter
, LPPRINTER_DEFAULTSA pDefault
)
1155 FIXME("(%d, %p): stub\n", hPrinter
, pDefault
);
1159 /*****************************************************************************
1160 * ResetPrinter32W [WINSPOOL.204]
1162 BOOL WINAPI
ResetPrinterW(HANDLE hPrinter
, LPPRINTER_DEFAULTSW pDefault
)
1164 FIXME("(%d, %p): stub\n", hPrinter
, pDefault
);
1168 /*****************************************************************************
1169 * GetPrinter32A [WINSPOOL.187]
1171 BOOL WINAPI
GetPrinterA(HANDLE hPrinter
, DWORD Level
, LPBYTE pPrinter
,
1172 DWORD cbBuf
, LPDWORD pcbNeeded
)
1174 FIXME("(%d,%ld,%p,%ld,%p): stub\n", hPrinter
, Level
, pPrinter
,
1177 *pcbNeeded
= sizeof(PRINTER_INFO_2A
);
1179 if(cbBuf
< *pcbNeeded
) {
1180 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1183 memset(pPrinter
, 0, cbBuf
);
1188 /*****************************************************************************
1189 * GetPrinter32W [WINSPOOL.194]
1191 BOOL WINAPI
GetPrinterW(HANDLE hPrinter
, DWORD Level
, LPBYTE pPrinter
,
1192 DWORD cbBuf
, LPDWORD pcbNeeded
)
1194 FIXME("(%d,%ld,%p,%ld,%p): stub\n", hPrinter
, Level
, pPrinter
,
1199 /*****************************************************************************
1200 * GetPrinterDriver32A [WINSPOOL.190]
1202 BOOL WINAPI
GetPrinterDriverA(HANDLE hPrinter
, LPSTR pEnvironment
,
1203 DWORD Level
, LPBYTE pDriverInfo
,
1204 DWORD cbBuf
, LPDWORD pcbNeeded
)
1206 OPENEDPRINTERA
*lpOpenedPrinter
;
1209 FIXME("(%d,%s,%ld,%p,%ld,%p): stub\n",hPrinter
,pEnvironment
,
1210 Level
,pDriverInfo
,cbBuf
, pcbNeeded
);
1212 lpOpenedPrinter
= WINSPOOL_GetOpenedPrinterA(hPrinter
);
1213 if(!lpOpenedPrinter
) {
1214 SetLastError(ERROR_INVALID_HANDLE
);
1217 lpName
= lpOpenedPrinter
->lpsPrinterName
;
1219 FIXME("pEnvironment = `%s'\n", pEnvironment
);
1220 SetLastError(ERROR_INVALID_ENVIRONMENT
);
1227 /*****************************************************************************
1228 * GetPrinterDriver32W [WINSPOOL.193]
1230 BOOL WINAPI
GetPrinterDriverW(HANDLE hPrinter
, LPWSTR pEnvironment
,
1231 DWORD Level
, LPBYTE pDriverInfo
,
1232 DWORD cbBuf
, LPDWORD pcbNeeded
)
1234 FIXME("(%d,%p,%ld,%p,%ld,%p): stub\n",hPrinter
,pEnvironment
,
1235 Level
,pDriverInfo
,cbBuf
, pcbNeeded
);
1239 /*****************************************************************************
1240 * GetPrinterDriverDirectoryA [WINSPOOL.191]
1242 BOOL WINAPI
GetPrinterDriverDirectoryA(LPSTR pName
, LPSTR pEnvironment
,
1243 DWORD Level
, LPBYTE pDriverDirectory
,
1244 DWORD cbBuf
, LPDWORD pcbNeeded
)
1248 TRACE("(%s, %s, %ld, %p, %ld, %p)\n", pName
, pEnvironment
, Level
,
1249 pDriverDirectory
, cbBuf
, pcbNeeded
);
1251 FIXME("pName = `%s' - unsupported\n", pName
);
1252 SetLastError(ERROR_INVALID_PARAMETER
);
1255 if(pEnvironment
!= NULL
) {
1256 FIXME("pEnvironment = `%s' - unsupported\n", pEnvironment
);
1257 SetLastError(ERROR_INVALID_ENVIRONMENT
);
1260 if(Level
!= 1) /* win95 ignores this so we just carry on */
1261 WARN("Level = %ld - assuming 1\n", Level
);
1263 /* FIXME should read from registry */
1264 needed
= GetSystemDirectoryA(pDriverDirectory
, cbBuf
);
1267 *pcbNeeded
= needed
;
1268 if(needed
> cbBuf
) {
1269 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1276 /*****************************************************************************
1277 * GetPrinterDriverDirectoryW [WINSPOOL.192]
1279 BOOL WINAPI
GetPrinterDriverDirectoryW(LPWSTR pName
, LPWSTR pEnvironment
,
1280 DWORD Level
, LPBYTE pDriverDirectory
,
1281 DWORD cbBuf
, LPDWORD pcbNeeded
)
1283 LPSTR pNameA
= NULL
, pEnvironmentA
= NULL
;
1287 pNameA
= HEAP_strdupWtoA( GetProcessHeap(), 0, pName
);
1289 pEnvironmentA
= HEAP_strdupWtoA( GetProcessHeap(), 0, pEnvironment
);
1290 ret
= GetPrinterDriverDirectoryA( pNameA
, pEnvironmentA
, Level
,
1291 pDriverDirectory
, cbBuf
, pcbNeeded
);
1293 HeapFree( GetProcessHeap(), 0, pNameA
);
1295 HeapFree( GetProcessHeap(), 0, pEnvironment
);
1300 /*****************************************************************************
1301 * AddPrinterDriver32A [WINSPOOL.120]
1303 BOOL WINAPI
AddPrinterDriverA(LPSTR pName
, DWORD level
, LPBYTE pDriverInfo
)
1306 HKEY hkeyDrivers
, hkeyName
;
1308 TRACE("(%s,%ld,%p)\n",pName
,level
,pDriverInfo
);
1310 if(level
!= 2 && level
!= 3) {
1311 SetLastError(ERROR_INVALID_LEVEL
);
1315 FIXME("pName= `%s' - unsupported\n", pName
);
1316 SetLastError(ERROR_INVALID_PARAMETER
);
1320 WARN("pDriverInfo == NULL");
1321 SetLastError(ERROR_INVALID_PARAMETER
);
1326 di3
= *(DRIVER_INFO_3A
*)pDriverInfo
;
1328 memset(&di3
, 0, sizeof(di3
));
1329 *(DRIVER_INFO_2A
*)&di3
= *(DRIVER_INFO_2A
*)pDriverInfo
;
1332 if(!di3
.pName
|| !di3
.pDriverPath
|| !di3
.pConfigFile
||
1334 SetLastError(ERROR_INVALID_PARAMETER
);
1337 if(!di3
.pDefaultDataType
) di3
.pDefaultDataType
= "";
1338 if(!di3
.pDependentFiles
) di3
.pDependentFiles
= "\0";
1339 if(!di3
.pHelpFile
) di3
.pHelpFile
= "";
1340 if(!di3
.pMonitorName
) di3
.pMonitorName
= "";
1342 if(di3
.pEnvironment
) {
1343 FIXME("pEnvironment = `%s'\n", di3
.pEnvironment
);
1344 SetLastError(ERROR_INVALID_ENVIRONMENT
);
1347 if(RegCreateKeyA(HKEY_LOCAL_MACHINE
, Drivers
, &hkeyDrivers
) !=
1349 ERR("Can't create Drivers key\n");
1353 if(level
== 2) { /* apparently can't overwrite with level2 */
1354 if(RegOpenKeyA(hkeyDrivers
, di3
.pName
, &hkeyName
) == ERROR_SUCCESS
) {
1355 RegCloseKey(hkeyName
);
1356 RegCloseKey(hkeyDrivers
);
1357 WARN("Trying to create existing printer driver `%s'\n", di3
.pName
);
1358 SetLastError(ERROR_PRINTER_DRIVER_ALREADY_INSTALLED
);
1362 if(RegCreateKeyA(hkeyDrivers
, di3
.pName
, &hkeyName
) != ERROR_SUCCESS
) {
1363 RegCloseKey(hkeyDrivers
);
1364 ERR("Can't create Name key\n");
1367 RegSetValueExA(hkeyName
, "Configuration File", 0, REG_SZ
, di3
.pConfigFile
,
1369 RegSetValueExA(hkeyName
, "Data File", 0, REG_SZ
, di3
.pDataFile
, 0);
1370 RegSetValueExA(hkeyName
, "Driver", 0, REG_SZ
, di3
.pDriverPath
, 0);
1371 RegSetValueExA(hkeyName
, "Version", 0, REG_DWORD
, (LPSTR
)&di3
.cVersion
,
1373 RegSetValueExA(hkeyName
, "Datatype", 0, REG_SZ
, di3
.pDefaultDataType
, 0);
1374 RegSetValueExA(hkeyName
, "Dependent Files", 0, REG_MULTI_SZ
,
1375 di3
.pDependentFiles
, 0);
1376 RegSetValueExA(hkeyName
, "Help File", 0, REG_SZ
, di3
.pHelpFile
, 0);
1377 RegSetValueExA(hkeyName
, "Monitor", 0, REG_SZ
, di3
.pMonitorName
, 0);
1378 RegCloseKey(hkeyName
);
1379 RegCloseKey(hkeyDrivers
);
1383 /*****************************************************************************
1384 * AddPrinterDriver32W [WINSPOOL.121]
1386 BOOL WINAPI
AddPrinterDriverW(LPWSTR printerName
,DWORD level
,
1389 FIXME("(%s,%ld,%p): stub\n",debugstr_w(printerName
),
1395 /*****************************************************************************
1396 * PrinterProperties [WINSPOOL.201]
1398 * Displays a dialog to set the properties of the printer.
1401 * nonzero on succes or zero on faillure
1404 * implemented as stub only
1406 BOOL WINAPI
PrinterProperties(HWND hWnd
, /* handle to parent window */
1407 HANDLE hPrinter
/* handle to printer object */
1409 FIXME("(%d,%d): stub\n", hWnd
, hPrinter
);
1410 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);