2 * Implementation of some printer driver bits
4 * Copyright 1996 John Harvey
5 * Copyright 1998 Andreas Mohr
17 static char PrinterModel[] = "Printer Model";
18 static char DefaultDevMode[] = "Default DevMode";
19 static char PrinterDriverData[] = "PrinterDriverData";
20 static char Printers[] = "System\\CurrentControlSet\\Control\\Print\\Printers\\";
22 /******************************************************************
23 * StartDoc16 [GDI.377]
26 INT16 WINAPI StartDoc16( HDC16 hdc, const DOCINFO16 *lpdoc )
29 TRACE(print,"(%p)\n", lpdoc );
30 TRACE(print,"%d 0x%lx:0x%p 0x%lx:0x%p\n",lpdoc->cbSize,
31 lpdoc->lpszDocName,PTR_SEG_TO_LIN(lpdoc->lpszDocName),
32 lpdoc->lpszOutput,PTR_SEG_TO_LIN(lpdoc->lpszOutput));
33 TRACE(print, "%d %s %s\n",lpdoc->cbSize,
34 (LPSTR)PTR_SEG_TO_LIN(lpdoc->lpszDocName),
35 (LPSTR)PTR_SEG_TO_LIN(lpdoc->lpszOutput));
36 retVal = Escape16(hdc, STARTDOC,
37 strlen((LPSTR)PTR_SEG_TO_LIN(lpdoc->lpszDocName)), lpdoc->lpszDocName, 0);
38 TRACE(print,"Escape16 returned %d\n",retVal);
42 /******************************************************************
46 INT16 WINAPI EndPage16( HDC16 hdc )
49 retVal = Escape16(hdc, NEWFRAME, 0, 0, 0);
50 TRACE(print,"Escape16 returned %d\n",retVal);
54 /******************************************************************
55 * StartDoc32A [GDI32.347]
58 INT WINAPI StartDocA(HDC hdc ,const DOCINFOA* doc)
61 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
62 return 0; /* failure*/
65 /*************************************************************************
66 * StartDoc32W [GDI32.348]
69 INT WINAPI StartDocW(HDC hdc, const DOCINFOW* doc) {
71 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
72 return 0; /* failure*/
75 /******************************************************************
76 * StartPage32 [GDI32.349]
79 INT WINAPI StartPage(HDC hdc)
82 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
83 return 0; /* failure*/
86 /******************************************************************
87 * EndPage32 [GDI32.77]
90 INT WINAPI EndPage(HDC hdc)
93 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
94 return 0; /* failure*/
97 /******************************************************************
101 INT16 WINAPI EndDoc16(HDC16 hdc)
103 return Escape16(hdc, ENDDOC, 0, 0, 0);
106 /******************************************************************
107 * EndDoc32 [GDI32.76]
110 INT WINAPI EndDoc(HDC hdc)
113 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
114 return 0; /* failure*/
117 /******************************************************************************
118 * AbortDoc16 [GDI.382]
120 INT16 WINAPI AbortDoc16(HDC16 hdc)
122 return Escape16(hdc, ABORTDOC, 0, 0, 0);
125 /******************************************************************************
126 * AbortDoc32 [GDI32.0]
128 INT WINAPI AbortDoc(HDC hdc)
130 FIXME(gdi, "(%d): stub\n", hdc);
134 /******************************************************************
135 * DrvGetPrinterDataInternal
137 * Helper for DrvGetPrinterData
139 static DWORD DrvGetPrinterDataInternal(LPSTR RegStr_Printer,
140 LPBYTE lpPrinterData, int cbData, int what)
144 DWORD dwType, cbQueryData;
146 if (!(RegOpenKeyA(HKEY_LOCAL_MACHINE, RegStr_Printer, &hkey))) {
147 if (what == INT_PD_DEFAULT_DEVMODE) { /* "Default DevMode" */
148 if (!(RegQueryValueExA(hkey, DefaultDevMode, 0, &dwType, 0, &cbQueryData))) {
151 else if ((cbQueryData) && (cbQueryData <= cbData)) {
152 cbQueryData = cbData;
153 if (RegQueryValueExA(hkey, DefaultDevMode, 0,
154 &dwType, lpPrinterData, &cbQueryData))
158 } else { /* "Printer Driver" */
160 RegQueryValueExA(hkey, "Printer Driver", 0,
161 &dwType, lpPrinterData, &cbQueryData);
165 if (hkey) RegCloseKey(hkey);
169 /******************************************************************
170 * DrvGetPrinterData [GDI.282]
173 DWORD WINAPI DrvGetPrinterData16(LPSTR lpPrinter, LPSTR lpProfile,
174 LPDWORD lpType, LPBYTE lpPrinterData,
175 int cbData, LPDWORD lpNeeded)
177 LPSTR RegStr_Printer;
178 HKEY hkey = 0, hkey2 = 0;
180 DWORD dwType, PrinterAttr, cbPrinterAttr, SetData, size;
182 if (HIWORD(lpPrinter))
183 TRACE(print,"printer %s\n",lpPrinter);
185 TRACE(print,"printer %p\n",lpPrinter);
186 if (HIWORD(lpProfile))
187 TRACE(print,"profile %s\n",lpProfile);
189 TRACE(print,"profile %p\n",lpProfile);
190 TRACE(print,"lpType %p\n",lpType);
192 if ((!lpPrinter) || (!lpProfile) || (!lpNeeded))
193 return ERROR_INVALID_PARAMETER;
195 RegStr_Printer = HeapAlloc(GetProcessHeap(), 0,
196 strlen(Printers) + strlen(lpPrinter) + 2);
197 strcpy(RegStr_Printer, Printers);
198 strcat(RegStr_Printer, lpPrinter);
200 if (((DWORD)lpProfile == INT_PD_DEFAULT_DEVMODE) || (HIWORD(lpProfile) &&
201 (!strcmp(lpProfile, DefaultDevMode)))) {
202 size = DrvGetPrinterDataInternal(RegStr_Printer, lpPrinterData, cbData,
203 INT_PD_DEFAULT_DEVMODE);
206 if ((lpPrinterData) && (*lpNeeded > cbData))
207 res = ERROR_MORE_DATA;
209 else res = ERROR_INVALID_PRINTER_NAME;
212 if (((DWORD)lpProfile == INT_PD_DEFAULT_MODEL) || (HIWORD(lpProfile) &&
213 (!strcmp(lpProfile, PrinterModel)))) {
215 if (!lpPrinterData) goto failed;
217 res = ERROR_MORE_DATA;
220 size = DrvGetPrinterDataInternal(RegStr_Printer, lpPrinterData, cbData,
221 INT_PD_DEFAULT_MODEL);
222 if ((size+1) && (lpType))
225 res = ERROR_INVALID_PRINTER_NAME;
229 if ((res = RegOpenKeyA(HKEY_LOCAL_MACHINE, RegStr_Printer, &hkey)))
232 if ((res = RegQueryValueExA(hkey, "Attributes", 0,
233 &dwType, (LPBYTE)&PrinterAttr, &cbPrinterAttr)))
235 if ((res = RegOpenKeyA(hkey, PrinterDriverData, &hkey2)))
238 res = RegQueryValueExA(hkey2, lpProfile, 0,
239 lpType, lpPrinterData, lpNeeded);
240 if ((res != ERROR_CANTREAD) &&
242 (PRINTER_ATTRIBUTE_ENABLE_BIDI|PRINTER_ATTRIBUTE_NETWORK))
243 == PRINTER_ATTRIBUTE_NETWORK))
245 if (!(res) && (*lpType == REG_DWORD) && (*(LPDWORD)lpPrinterData == -1))
246 res = ERROR_INVALID_DATA;
251 RegSetValueExA(hkey2, lpProfile, 0, REG_DWORD, (LPBYTE)&SetData, 4); /* no result returned */
256 if (hkey2) RegCloseKey(hkey2);
257 if (hkey) RegCloseKey(hkey);
258 HeapFree(GetProcessHeap(), 0, RegStr_Printer);
263 /******************************************************************
264 * DrvSetPrinterData [GDI.281]
267 DWORD WINAPI DrvSetPrinterData16(LPSTR lpPrinter, LPSTR lpProfile,
268 DWORD lpType, LPBYTE lpPrinterData,
271 LPSTR RegStr_Printer;
275 if (HIWORD(lpPrinter))
276 TRACE(print,"printer %s\n",lpPrinter);
278 TRACE(print,"printer %p\n",lpPrinter);
279 if (HIWORD(lpProfile))
280 TRACE(print,"profile %s\n",lpProfile);
282 TRACE(print,"profile %p\n",lpProfile);
283 TRACE(print,"lpType %08lx\n",lpType);
285 if ((!lpPrinter) || (!lpProfile) ||
286 ((DWORD)lpProfile == INT_PD_DEFAULT_MODEL) || (HIWORD(lpProfile) &&
287 (!strcmp(lpProfile, PrinterModel))))
288 return ERROR_INVALID_PARAMETER;
290 RegStr_Printer = HeapAlloc(GetProcessHeap(), 0,
291 strlen(Printers) + strlen(lpPrinter) + 2);
292 strcpy(RegStr_Printer, Printers);
293 strcat(RegStr_Printer, lpPrinter);
295 if (((DWORD)lpProfile == INT_PD_DEFAULT_DEVMODE) || (HIWORD(lpProfile) &&
296 (!strcmp(lpProfile, DefaultDevMode)))) {
297 if ( RegOpenKeyA(HKEY_LOCAL_MACHINE, RegStr_Printer, &hkey)
299 RegSetValueExA(hkey, DefaultDevMode, 0, REG_BINARY,
300 lpPrinterData, dwSize) != ERROR_SUCCESS )
301 res = ERROR_INVALID_PRINTER_NAME;
305 strcat(RegStr_Printer, "\\");
307 if( (res = RegOpenKeyA(HKEY_LOCAL_MACHINE, RegStr_Printer, &hkey)) ==
311 res = RegDeleteValueA(hkey, lpProfile);
313 res = RegSetValueExA(hkey, lpProfile, 0, lpType,
314 lpPrinterData, dwSize);
318 if (hkey) RegCloseKey(hkey);
319 HeapFree(GetProcessHeap(), 0, RegStr_Printer);
324 /******************************************************************
325 * DeviceCapabilities32A [WINSPOOL.151]
328 INT WINAPI DeviceCapabilitiesA(LPCSTR printer,LPCSTR target,WORD z,
329 LPSTR a,LPDEVMODEA b)
331 FIXME(print,"(%s,%s,%d,%p,%p):stub.\n",printer,target,z,a,b);
336 /*****************************************************************************
337 * DeviceCapabilities32W
339 INT WINAPI DeviceCapabilitiesW(LPCWSTR pDevice, LPCWSTR pPort,
340 WORD fwCapability, LPWSTR pOutput,
341 const DEVMODEW *pDevMode)
343 FIXME(print,"(%p,%p,%d,%p,%p): stub\n",
344 pDevice, pPort, fwCapability, pOutput, pDevMode);
348 /******************************************************************
349 * DocumentProperties32A [WINSPOOL.155]
352 LONG WINAPI DocumentPropertiesA(HWND hWnd,HANDLE hPrinter,
353 LPSTR pDeviceName, LPDEVMODEA pDevModeOutput,
354 LPDEVMODEA pDevModeInput,DWORD fMode )
356 FIXME(print,"(%d,%d,%s,%p,%p,%ld):stub.\n",
357 hWnd,hPrinter,pDeviceName,pDevModeOutput,pDevModeInput,fMode
363 /*****************************************************************************
364 * DocumentProperties32W
366 LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter,
368 LPDEVMODEW pDevModeOutput,
369 LPDEVMODEW pDevModeInput, DWORD fMode)
371 FIXME(print,"(%d,%d,%s,%p,%p,%ld): stub\n",
372 hWnd,hPrinter,debugstr_w(pDeviceName),pDevModeOutput,pDevModeInput,
378 /******************************************************************
379 * OpenPrinter32A [WINSPOOL.196]
382 BOOL WINAPI OpenPrinterA(LPSTR lpPrinterName,HANDLE *phPrinter,
383 LPPRINTER_DEFAULTSA pDefault)
385 FIXME(print,"(%s,%p,%p):stub\n",debugstr_a(lpPrinterName), phPrinter,
387 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
391 /******************************************************************
392 * OpenPrinter32W [WINSPOOL.197]
395 BOOL WINAPI OpenPrinterW(LPWSTR lpPrinterName,HANDLE *phPrinter,
396 LPPRINTER_DEFAULTSW pDefault)
398 FIXME(print,"(%s,%p,%p):stub\n",debugstr_w(lpPrinterName), phPrinter,
400 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
404 /******************************************************************
405 * EnumPrinters32A [WINSPOOL.174]
408 BOOL WINAPI EnumPrintersA(DWORD dwType, LPSTR lpszName,
409 DWORD dwLevel, LPBYTE lpbPrinters,
410 DWORD cbBuf, LPDWORD lpdwNeeded,
411 LPDWORD lpdwReturned)
413 FIXME(print,"Nearly empty stub\n");
419 /******************************************************************
420 * EnumPrinters32W [WINSPOOL.175]
423 BOOL WINAPI EnumPrintersW(DWORD dwType, LPWSTR lpszName,
424 DWORD dwLevel, LPBYTE lpbPrinters,
425 DWORD cbBuf, LPDWORD lpdwNeeded,
426 LPDWORD lpdwReturned)
428 FIXME(print,"Nearly empty stub\n");
434 /******************************************************************
435 * AddMonitor32A [WINSPOOL.107]
438 BOOL WINAPI AddMonitorA(LPCSTR pName, DWORD Level, LPBYTE pMonitors)
440 FIXME(print, "(%s,%lx,%p):stub!\n", pName, Level, pMonitors);
441 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
445 /******************************************************************
446 * DeletePrinterDriver32A [WINSPOOL.146]
450 DeletePrinterDriverA (LPSTR pName, LPSTR pEnvironment, LPSTR pDriverName)
452 FIXME(print,"(%s,%s,%s):stub\n",debugstr_a(pName),debugstr_a(pEnvironment),
453 debugstr_a(pDriverName));
454 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
459 /******************************************************************
460 * DeleteMonitor32A [WINSPOOL.135]
464 DeleteMonitorA (LPSTR pName, LPSTR pEnvironment, LPSTR pMonitorName)
466 FIXME(print,"(%s,%s,%s):stub\n",debugstr_a(pName),debugstr_a(pEnvironment),
467 debugstr_a(pMonitorName));
468 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
473 /******************************************************************
474 * DeletePort32A [WINSPOOL.137]
478 DeletePortA (LPSTR pName, HWND hWnd, LPSTR pPortName)
480 FIXME(print,"(%s,0x%08x,%s):stub\n",debugstr_a(pName),hWnd,
481 debugstr_a(pPortName));
482 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
486 /******************************************************************************
487 * SetPrinter32W [WINSPOOL.214]
496 FIXME(print,"():stub\n");
497 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
501 /******************************************************************************
502 * WritePrinter32 [WINSPOOL.223]
511 FIXME(print,"():stub\n");
512 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
516 /*****************************************************************************
517 * AddForm32A [WINSPOOL.103]
519 BOOL WINAPI AddFormA(HANDLE hPrinter, DWORD Level, LPBYTE pForm)
521 FIXME(print, "(%d,%ld,%p): stub\n", hPrinter, Level, pForm);
525 /*****************************************************************************
526 * AddForm32W [WINSPOOL.104]
528 BOOL WINAPI AddFormW(HANDLE hPrinter, DWORD Level, LPBYTE pForm)
530 FIXME(print, "(%d,%ld,%p): stub\n", hPrinter, Level, pForm);
534 /*****************************************************************************
535 * AddJob32A [WINSPOOL.105]
537 BOOL WINAPI AddJobA(HANDLE hPrinter, DWORD Level, LPBYTE pData,
538 DWORD cbBuf, LPDWORD pcbNeeded)
540 FIXME(print, "(%d,%ld,%p,%ld,%p): stub\n", hPrinter, Level, pData, cbBuf,
545 /*****************************************************************************
546 * AddJob32W [WINSPOOL.106]
548 BOOL WINAPI AddJobW(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf,
551 FIXME(print, "(%d,%ld,%p,%ld,%p): stub\n", hPrinter, Level, pData, cbBuf,
556 /*****************************************************************************
557 * AddPrinter32A [WINSPOOL.117]
559 HANDLE WINAPI AddPrinterA(LPSTR pName, DWORD Level, LPBYTE pPrinter)
561 FIXME(print, "(%s,%ld,%p): stub\n", pName, Level, pPrinter);
565 /*****************************************************************************
566 * AddPrinter32W [WINSPOOL.122]
568 HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
570 FIXME(print, "(%p,%ld,%p): stub\n", pName, Level, pPrinter);
575 /*****************************************************************************
576 * ClosePrinter32 [WINSPOOL.126]
578 BOOL WINAPI ClosePrinter(HANDLE hPrinter)
580 FIXME(print, "(%d): stub\n", hPrinter);
584 /*****************************************************************************
585 * DeleteForm32A [WINSPOOL.133]
587 BOOL WINAPI DeleteFormA(HANDLE hPrinter, LPSTR pFormName)
589 FIXME(print, "(%d,%s): stub\n", hPrinter, pFormName);
593 /*****************************************************************************
594 * DeleteForm32W [WINSPOOL.134]
596 BOOL WINAPI DeleteFormW(HANDLE hPrinter, LPWSTR pFormName)
598 FIXME(print, "(%d,%s): stub\n", hPrinter, debugstr_w(pFormName));
602 /*****************************************************************************
603 * DeletePrinter32 [WINSPOOL.143]
605 BOOL WINAPI DeletePrinter(HANDLE hPrinter)
607 FIXME(print, "(%d): stub\n", hPrinter);
611 /*****************************************************************************
612 * SetPrinter32A [WINSPOOL.211]
614 BOOL WINAPI SetPrinterA(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
617 FIXME(print, "(%d,%ld,%p,%ld): stub\n",hPrinter,Level,pPrinter,Command);
621 /*****************************************************************************
622 * SetJob32A [WINSPOOL.209]
624 BOOL WINAPI SetJobA(HANDLE hPrinter, DWORD JobId, DWORD Level,
625 LPBYTE pJob, DWORD Command)
627 FIXME(print, "(%d,%ld,%ld,%p,%ld): stub\n",hPrinter,JobId,Level,pJob,
632 /*****************************************************************************
633 * SetJob32W [WINSPOOL.210]
635 BOOL WINAPI SetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level,
636 LPBYTE pJob, DWORD Command)
638 FIXME(print, "(%d,%ld,%ld,%p,%ld): stub\n",hPrinter,JobId,Level,pJob,
643 /*****************************************************************************
644 * GetForm32A [WINSPOOL.181]
646 BOOL WINAPI GetFormA(HANDLE hPrinter, LPSTR pFormName, DWORD Level,
647 LPBYTE pForm, DWORD cbBuf, LPDWORD pcbNeeded)
649 FIXME(print, "(%d,%s,%ld,%p,%ld,%p): stub\n",hPrinter,pFormName,
650 Level,pForm,cbBuf,pcbNeeded);
654 /*****************************************************************************
655 * GetForm32W [WINSPOOL.182]
657 BOOL WINAPI GetFormW(HANDLE hPrinter, LPWSTR pFormName, DWORD Level,
658 LPBYTE pForm, DWORD cbBuf, LPDWORD pcbNeeded)
660 FIXME(print, "(%d,%s,%ld,%p,%ld,%p): stub\n",hPrinter,
661 debugstr_w(pFormName),Level,pForm,cbBuf,pcbNeeded);
665 /*****************************************************************************
666 * SetForm32A [WINSPOOL.207]
668 BOOL WINAPI SetFormA(HANDLE hPrinter, LPSTR pFormName, DWORD Level,
671 FIXME(print, "(%d,%s,%ld,%p): stub\n",hPrinter,pFormName,Level,pForm);
675 /*****************************************************************************
676 * SetForm32W [WINSPOOL.208]
678 BOOL WINAPI SetFormW(HANDLE hPrinter, LPWSTR pFormName, DWORD Level,
681 FIXME(print, "(%d,%p,%ld,%p): stub\n",hPrinter,pFormName,Level,pForm);
685 /*****************************************************************************
686 * ReadPrinter32 [WINSPOOL.202]
688 BOOL WINAPI ReadPrinter(HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf,
689 LPDWORD pNoBytesRead)
691 FIXME(print, "(%d,%p,%ld,%p): stub\n",hPrinter,pBuf,cbBuf,pNoBytesRead);
695 /*****************************************************************************
696 * ResetPrinter32A [WINSPOOL.203]
698 BOOL WINAPI ResetPrinterA(HANDLE hPrinter, LPPRINTER_DEFAULTSA pDefault)
700 FIXME(print, "(%d, %p): stub\n", hPrinter, pDefault);
704 /*****************************************************************************
705 * ResetPrinter32W [WINSPOOL.204]
707 BOOL WINAPI ResetPrinterW(HANDLE hPrinter, LPPRINTER_DEFAULTSW pDefault)
709 FIXME(print, "(%d, %p): stub\n", hPrinter, pDefault);
713 /*****************************************************************************
714 * GetPrinter32A [WINSPOOL.187]
716 BOOL WINAPI GetPrinterA(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
717 DWORD cbBuf, LPDWORD pcbNeeded)
719 FIXME(print, "(%d,%ld,%p,%ld,%p): stub\n", hPrinter, Level, pPrinter,
724 /*****************************************************************************
725 * GetPrinter32W [WINSPOOL.194]
727 BOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
728 DWORD cbBuf, LPDWORD pcbNeeded)
730 FIXME(print, "(%d,%ld,%p,%ld,%p): stub\n", hPrinter, Level, pPrinter,
735 /*****************************************************************************
736 * GetPrinterDriver32A [WINSPOOL.190]
738 BOOL WINAPI GetPrinterDriverA(HANDLE hPrinter, LPSTR pEnvironment,
739 DWORD Level, LPBYTE pDriverInfo,
740 DWORD cbBuf, LPDWORD pcbNeeded)
742 FIXME(print, "(%d,%s,%ld,%p,%ld,%p): stub\n",hPrinter,pEnvironment,
743 Level,pDriverInfo,cbBuf, pcbNeeded);
747 /*****************************************************************************
748 * GetPrinterDriver32W [WINSPOOL.193]
750 BOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment,
751 DWORD Level, LPBYTE pDriverInfo,
752 DWORD cbBuf, LPDWORD pcbNeeded)
754 FIXME(print, "(%d,%p,%ld,%p,%ld,%p): stub\n",hPrinter,pEnvironment,
755 Level,pDriverInfo,cbBuf, pcbNeeded);
758 /*****************************************************************************
759 * AddPrinterDriver32A [WINSPOOL.120]
761 BOOL WINAPI AddPrinterDriverA(LPSTR printerName,DWORD level,
764 FIXME(print, "(%s,%ld,%p): stub\n",printerName,level,pDriverInfo);
767 /*****************************************************************************
768 * AddPrinterDriver32W [WINSPOOL.121]
770 BOOL WINAPI AddPrinterDriverW(LPWSTR printerName,DWORD level,
773 FIXME(print, "(%s,%ld,%p): stub\n",debugstr_w(printerName),