2 * Copyright (C) 2003, 2004 Stefan Leichter
3 * Copyright (C) 2005, 2006 Detlef Riekenberg
4 * Copyright (C) 2006 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/test.h"
32 #define MAGIC_DEAD 0x00dead00
33 #define DEFAULT_PRINTER_SIZE 1000
35 static char env_x86[] = "Windows NT x86";
36 static char env_win9x_case[] = "windowS 4.0";
37 static char winetest_monitor[] = "winetest";
39 static HANDLE hwinspool;
40 static FARPROC pGetDefaultPrinterA;
41 static FARPROC pSetDefaultPrinterA;
43 struct monitor_entry {
48 /* report common behavior only once */
49 static DWORD report_deactivated_spooler = 1;
50 #define RETURN_ON_DEACTIVATED_SPOOLER(res) \
51 if((res == 0) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE)) \
53 if(report_deactivated_spooler > 0) { \
54 report_deactivated_spooler--; \
55 trace("The Service 'Spooler' is required for many test\n"); \
61 static LPSTR find_default_printer(VOID)
63 static LPSTR default_printer = NULL;
64 static char buffer[DEFAULT_PRINTER_SIZE];
69 if ((default_printer == NULL) && (pGetDefaultPrinterA))
72 needed = sizeof(buffer);
73 res = pGetDefaultPrinterA(buffer, &needed);
74 if(res) default_printer = buffer;
75 trace("default_printer: '%s'\n", default_printer);
77 if (default_printer == NULL)
81 /* NT 3.x and above */
82 if (RegOpenKeyEx(HKEY_CURRENT_USER,
83 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows",
84 0, KEY_QUERY_VALUE, &hwindows) == NO_ERROR) {
86 needed = sizeof(buffer);
87 if (RegQueryValueEx(hwindows, "device", NULL,
88 &type, (LPBYTE)buffer, &needed) == NO_ERROR) {
90 ptr = strchr(buffer, ',');
93 default_printer = buffer;
96 RegCloseKey(hwindows);
98 trace("default_printer: '%s'\n", default_printer);
100 if (default_printer == NULL)
103 needed = sizeof(buffer);
104 res = GetProfileStringA("windows", "device", "*", buffer, needed);
106 ptr = strchr(buffer, ',');
109 default_printer = buffer;
112 trace("default_printer: '%s'\n", default_printer);
114 return default_printer;
118 static struct monitor_entry * find_installed_monitor(void)
120 MONITOR_INFO_2A mi2a;
121 static struct monitor_entry * entry = NULL;
126 static struct monitor_entry monitor_table[] = {
127 {env_win9x_case, "localspl.dll"},
128 {env_x86, "localspl.dll"},
129 {env_win9x_case, "localmon.dll"},
130 {env_x86, "localmon.dll"},
131 {env_win9x_case, "tcpmon.dll"},
132 {env_x86, "tcpmon.dll"},
133 {env_win9x_case, "usbmon.dll"},
134 {env_x86, "usbmon.dll"},
135 {env_win9x_case, "mspp32.dll"},
136 {env_x86, "win32spl.dll"},
137 {env_x86, "redmonnt.dll"},
138 {env_x86, "redmon35.dll"},
139 {env_win9x_case, "redmon95.dll"},
140 {env_x86, "pdfcmnnt.dll"},
141 {env_win9x_case, "pdfcmn95.dll"},
144 if (entry) return entry;
146 num_tests = (sizeof(monitor_table)/sizeof(struct monitor_entry));
148 SetLastError(MAGIC_DEAD);
149 res = DeleteMonitorA(NULL, NULL, NULL);
150 if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) {
151 trace("DeleteMonitorA() not implemented yet\n");
155 SetLastError(MAGIC_DEAD);
156 res = AddMonitorA(NULL, 0, NULL);
157 if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) {
158 trace("AddMonitorA() not implemented yet\n");
163 DeleteMonitorA(NULL, env_x86, winetest_monitor);
164 DeleteMonitorA(NULL, env_win9x_case, winetest_monitor);
166 /* find a usable monitor from the table */
167 mi2a.pName = winetest_monitor;
168 while ((entry == NULL) && (i < num_tests)) {
169 entry = &monitor_table[i];
171 mi2a.pEnvironment = entry->env;
172 mi2a.pDLLName = entry->dllname;
174 if (AddMonitorA(NULL, 2, (LPBYTE) &mi2a)) {
176 trace("using '%s', '%s'\n", entry->env, entry->dllname);
177 DeleteMonitorA(NULL, entry->env, winetest_monitor);
187 /* ########################### */
190 static void test_AddMonitor(void)
192 MONITOR_INFO_2A mi2a;
193 struct monitor_entry * entry = NULL;
196 entry = find_installed_monitor();
198 SetLastError(MAGIC_DEAD);
199 res = AddMonitorA(NULL, 1, NULL);
200 ok(!res && (GetLastError() == ERROR_INVALID_LEVEL),
201 "returned %ld with %ld (expected '0' with ERROR_INVALID_LEVEL)\n",
202 res, GetLastError());
204 SetLastError(MAGIC_DEAD);
205 res = AddMonitorA(NULL, 3, NULL);
206 ok(!res && (GetLastError() == ERROR_INVALID_LEVEL),
207 "returned %ld with %ld (expected '0' with ERROR_INVALID_LEVEL)\n",
208 res, GetLastError());
211 /* This test crash with win9x on vmware (works with win9x on qemu 0.8.1) */
212 SetLastError(MAGIC_DEAD);
213 res = AddMonitorA(NULL, 2, NULL);
214 /* NT: unchanged, 9x: ERROR_PRIVILEGE_NOT_HELD */
216 ((GetLastError() == MAGIC_DEAD) ||
217 (GetLastError() == ERROR_PRIVILEGE_NOT_HELD)),
218 "returned %ld with %ld (expected '0' with: MAGIC_DEAD or " \
219 "ERROR_PRIVILEGE_NOT_HELD)\n", res, GetLastError());
222 ZeroMemory(&mi2a, sizeof(MONITOR_INFO_2A));
223 SetLastError(MAGIC_DEAD);
224 res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
225 RETURN_ON_DEACTIVATED_SPOOLER(res)
227 if (!res && (GetLastError() == ERROR_ACCESS_DENIED)) {
228 trace("skip tests (ACCESS_DENIED)\n");
232 /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_INVALID_ENVIRONMENT */
233 ok(!res && ((GetLastError() == ERROR_INVALID_PARAMETER) ||
234 (GetLastError() == ERROR_INVALID_ENVIRONMENT)),
235 "returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or " \
236 "ERROR_INVALID_ENVIRONMENT)\n", res, GetLastError());
239 trace("No usable Monitor found: Skip tests\n");
244 /* The Test is deactivated, because when mi2a.pName is NULL, the subkey
245 HKLM\System\CurrentControlSet\Control\Print\Monitors\C:\WINDOWS\SYSTEM
246 or HKLM\System\CurrentControlSet\Control\Print\Monitors\ì
247 is created on win9x and we do not want to hit this bug here. */
249 mi2a.pEnvironment = entry->env;
250 SetLastError(MAGIC_DEAD);
251 res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
252 /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
255 mi2a.pEnvironment = entry->env;
257 SetLastError(MAGIC_DEAD);
258 res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
259 /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
261 ((GetLastError() == ERROR_INVALID_PARAMETER) ||
262 (GetLastError() == ERROR_PRIVILEGE_NOT_HELD)),
263 "returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or " \
264 "ERROR_PRIVILEGE_NOT_HELD)\n",
265 res, GetLastError());
267 mi2a.pName = winetest_monitor;
268 SetLastError(MAGIC_DEAD);
269 res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
270 /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
272 ((GetLastError() == ERROR_INVALID_PARAMETER) ||
273 (GetLastError() == ERROR_PRIVILEGE_NOT_HELD)),
274 "returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or " \
275 "ERROR_PRIVILEGE_NOT_HELD)\n",
276 res, GetLastError());
279 SetLastError(MAGIC_DEAD);
280 res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
281 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
282 "returned %ld with %ld (expected '0' with ERROR_INVALID_PARAMETER)\n",
283 res, GetLastError());
286 mi2a.pDLLName = "does_not_exists.dll";
287 SetLastError(MAGIC_DEAD);
288 res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
289 /* NT: ERROR_MOD_NOT_FOUND, 9x: ERROR_INVALID_PARAMETER */
291 ((GetLastError() == ERROR_MOD_NOT_FOUND) ||
292 (GetLastError() == ERROR_INVALID_PARAMETER)),
293 "returned %ld with %ld (expected '0' with: ERROR_MOD_NOT_FOUND or " \
294 "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
296 mi2a.pDLLName = "version.dll";
297 SetLastError(MAGIC_DEAD);
298 res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
299 /* NT: ERROR_PROC_NOT_FOUND, 9x: ERROR_INVALID_PARAMETER */
302 ((GetLastError() == ERROR_PROC_NOT_FOUND) ||
303 (GetLastError() == ERROR_INVALID_PARAMETER)),
304 "returned %ld with %ld (expected '0' with: ERROR_PROC_NOT_FOUND or " \
305 "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
306 if (res) DeleteMonitorA(NULL, entry->env, winetest_monitor);
309 /* Test AddMonitor with real options */
310 mi2a.pDLLName = entry->dllname;
311 SetLastError(MAGIC_DEAD);
312 res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
313 ok(res, "returned %ld with %ld (expected '!= 0')\n", res, GetLastError());
315 /* add a monitor twice */
316 SetLastError(MAGIC_DEAD);
317 res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
318 /* NT: ERROR_PRINT_MONITOR_ALREADY_INSTALLED (3006), 9x: ERROR_ALREADY_EXISTS (183) */
320 ((GetLastError() == ERROR_PRINT_MONITOR_ALREADY_INSTALLED) ||
321 (GetLastError() == ERROR_ALREADY_EXISTS)),
322 "returned %ld with %ld (expected '0' with: " \
323 "ERROR_PRINT_MONITOR_ALREADY_INSTALLED or ERROR_ALREADY_EXISTS)\n",
324 res, GetLastError());
326 DeleteMonitorA(NULL, entry->env, winetest_monitor);
327 SetLastError(MAGIC_DEAD);
328 res = AddMonitorA("", 2, (LPBYTE) &mi2a);
329 ok(res, "returned %ld with %ld (expected '!= 0')\n", res, GetLastError());
332 DeleteMonitorA(NULL, entry->env, winetest_monitor);
336 /* ########################### */
338 static void test_DeleteMonitor(void)
340 MONITOR_INFO_2A mi2a;
341 struct monitor_entry * entry = NULL;
344 entry = find_installed_monitor();
347 trace("No usable Monitor found: Skip tests\n");
351 mi2a.pName = winetest_monitor;
352 mi2a.pEnvironment = entry->env;
353 mi2a.pDLLName = entry->dllname;
355 /* Testing DeleteMonitor with real options */
356 AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
358 SetLastError(MAGIC_DEAD);
359 res = DeleteMonitorA(NULL, entry->env, winetest_monitor);
360 ok(res, "returned %ld with %ld (expected '!= 0')\n", res, GetLastError());
362 /* Delete the Monitor twice */
363 SetLastError(MAGIC_DEAD);
364 res = DeleteMonitorA(NULL, entry->env, winetest_monitor);
365 /* NT: ERROR_UNKNOWN_PRINT_MONITOR (3000), 9x: ERROR_INVALID_PARAMETER (87) */
367 ((GetLastError() == ERROR_UNKNOWN_PRINT_MONITOR) ||
368 (GetLastError() == ERROR_INVALID_PARAMETER)),
369 "returned %ld with %ld (expected '0' with: ERROR_UNKNOWN_PRINT_MONITOR" \
370 " or ERROR_INVALID_PARAMETER)\n", res, GetLastError());
372 /* the environment */
373 AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
374 SetLastError(MAGIC_DEAD);
375 res = DeleteMonitorA(NULL, NULL, winetest_monitor);
376 ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
378 AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
379 SetLastError(MAGIC_DEAD);
380 res = DeleteMonitorA(NULL, "", winetest_monitor);
381 ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
383 AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
384 SetLastError(MAGIC_DEAD);
385 res = DeleteMonitorA(NULL, "bad_env", winetest_monitor);
386 ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
388 /* the monitor-name */
389 AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
390 SetLastError(MAGIC_DEAD);
391 res = DeleteMonitorA(NULL, entry->env, NULL);
392 /* NT: ERROR_INVALID_PARAMETER (87), 9x: ERROR_INVALID_NAME (123)*/
394 ((GetLastError() == ERROR_INVALID_PARAMETER) ||
395 (GetLastError() == ERROR_INVALID_NAME)),
396 "returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or " \
397 "ERROR_INVALID_NAME)\n", res, GetLastError());
399 AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
400 SetLastError(MAGIC_DEAD);
401 res = DeleteMonitorA(NULL, entry->env, "");
402 /* NT: ERROR_INVALID_PARAMETER (87), 9x: ERROR_INVALID_NAME (123)*/
404 ((GetLastError() == ERROR_INVALID_PARAMETER) ||
405 (GetLastError() == ERROR_INVALID_NAME)),
406 "returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or " \
407 "ERROR_INVALID_NAME)\n", res, GetLastError());
409 AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
410 SetLastError(MAGIC_DEAD);
411 res = DeleteMonitorA("", entry->env, winetest_monitor);
412 ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
415 DeleteMonitorA(NULL, entry->env, winetest_monitor);
419 /* ########################### */
421 static void test_EnumMonitors(void)
430 /* valid levels are 1 and 2 */
431 for(level = 0; level < 4; level++) {
433 pcReturned = MAGIC_DEAD;
434 SetLastError(MAGIC_DEAD);
435 res = EnumMonitorsA(NULL, level, NULL, 0, &cbBuf, &pcReturned);
437 RETURN_ON_DEACTIVATED_SPOOLER(res)
439 /* not implemented yet in wine */
440 if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
443 /* use only a short test, when we test with an invalid level */
444 if(!level || (level > 2)) {
445 ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
446 (res && (pcReturned == 0)),
447 "(%ld) returned %ld with %ld and 0x%08lx (expected '0' with " \
448 "ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
449 level, res, GetLastError(), pcReturned);
453 /* Level 2 is not supported on win9x */
454 if (!res && (GetLastError() == ERROR_INVALID_LEVEL)) {
455 trace("Level %ld not supported, skipping tests\n", level);
459 ok((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
460 "(%ld) returned %ld with %ld (expected '0' with " \
461 "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
464 trace("no valid buffer size returned, skipping tests\n");
468 buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
469 if (buffer == NULL) continue;
471 SetLastError(MAGIC_DEAD);
472 pcbNeeded = MAGIC_DEAD;
473 res = EnumMonitorsA(NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
474 ok(res, "(%ld) returned %ld with %ld (expected '!=0')\n",
475 level, res, GetLastError());
476 ok(pcbNeeded == cbBuf, "(%ld) returned %ld (expected %ld)\n",
477 level, pcbNeeded, cbBuf);
478 /* We can validate the returned Data with the Registry here */
481 SetLastError(MAGIC_DEAD);
482 pcReturned = MAGIC_DEAD;
483 pcbNeeded = MAGIC_DEAD;
484 res = EnumMonitorsA(NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
485 ok(res, "(%ld) returned %ld with %ld (expected '!=0')\n", level,
486 res, GetLastError());
487 ok(pcbNeeded == cbBuf, "(%ld) returned %ld (expected %ld)\n", level,
490 SetLastError(MAGIC_DEAD);
491 pcbNeeded = MAGIC_DEAD;
492 res = EnumMonitorsA(NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
493 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
494 "(%ld) returned %ld with %ld (expected '0' with " \
495 "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
497 ok(pcbNeeded == cbBuf, "(%ld) returned %ld (expected %ld)\n", level,
501 Do not add the next test:
502 w2k+: RPC_X_NULL_REF_POINTER
503 NT3.5: ERROR_INVALID_USER_BUFFER
504 win9x: crash in winspool.drv
506 res = EnumMonitorsA(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
509 SetLastError(MAGIC_DEAD);
510 pcbNeeded = MAGIC_DEAD;
511 pcReturned = MAGIC_DEAD;
512 res = EnumMonitorsA(NULL, level, buffer, cbBuf, NULL, &pcReturned);
513 ok( res || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)) ,
514 "(%ld) returned %ld with %ld (expected '!=0' or '0' with "\
515 "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
517 pcbNeeded = MAGIC_DEAD;
518 pcReturned = MAGIC_DEAD;
519 SetLastError(MAGIC_DEAD);
520 res = EnumMonitorsA(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
521 ok( res || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)) ,
522 "(%ld) returned %ld with %ld (expected '!=0' or '0' with "\
523 "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
525 HeapFree(GetProcessHeap(), 0, buffer);
526 } /* for(level ... */
530 static void test_GetDefaultPrinter(void)
533 DWORD exact = DEFAULT_PRINTER_SIZE;
535 char buffer[DEFAULT_PRINTER_SIZE];
537 if (!pGetDefaultPrinterA) return;
538 /* only supported on NT like OSes starting with win2k */
540 SetLastError(ERROR_SUCCESS);
541 retval = pGetDefaultPrinterA(buffer, &exact);
542 if (!retval || !exact || !strlen(buffer) ||
543 (ERROR_SUCCESS != GetLastError())) {
544 if ((ERROR_FILE_NOT_FOUND == GetLastError()) ||
545 (ERROR_INVALID_NAME == GetLastError()))
546 trace("this test requires a default printer to be set\n");
548 ok( 0, "function call GetDefaultPrinterA failed unexpected!\n"
549 "function returned %s\n"
550 "last error 0x%08lx\n"
551 "returned buffer size 0x%08lx\n"
552 "returned buffer content %s\n",
553 retval ? "true" : "false", GetLastError(), exact, buffer);
557 SetLastError(ERROR_SUCCESS);
558 retval = pGetDefaultPrinterA(NULL, NULL);
559 ok( !retval, "function result wrong! False expected\n");
560 ok( ERROR_INVALID_PARAMETER == GetLastError(),
561 "Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08lx\n",
564 SetLastError(ERROR_SUCCESS);
565 retval = pGetDefaultPrinterA(buffer, NULL);
566 ok( !retval, "function result wrong! False expected\n");
567 ok( ERROR_INVALID_PARAMETER == GetLastError(),
568 "Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08lx\n",
571 SetLastError(ERROR_SUCCESS);
573 retval = pGetDefaultPrinterA(NULL, &size);
574 ok( !retval, "function result wrong! False expected\n");
575 ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
576 "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08lx\n",
578 ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
581 SetLastError(ERROR_SUCCESS);
582 size = DEFAULT_PRINTER_SIZE;
583 retval = pGetDefaultPrinterA(NULL, &size);
584 ok( !retval, "function result wrong! False expected\n");
585 ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
586 "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08lx\n",
588 ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
592 retval = pGetDefaultPrinterA(buffer, &size);
593 ok( !retval, "function result wrong! False expected\n");
594 ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
595 "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08lx\n",
597 ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
601 retval = pGetDefaultPrinterA(buffer, &size);
602 ok( retval, "function result wrong! True expected\n");
603 ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
607 static void test_GetPrinterDriverDirectory(void)
609 LPBYTE buffer = NULL;
610 DWORD cbBuf = 0, pcbNeeded = 0;
613 SetLastError(MAGIC_DEAD);
614 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, 0, &cbBuf);
615 trace("first call returned 0x%04x, with %ld: buffer size 0x%08lx\n",
616 res, GetLastError(), cbBuf);
618 RETURN_ON_DEACTIVATED_SPOOLER(res)
619 ok((res == 0) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
620 "returned %d with lasterror=%ld (expected '0' with " \
621 "ERROR_INSUFFICIENT_BUFFER)\n", res, GetLastError());
624 trace("no valid buffer size returned, skipping tests\n");
628 buffer = HeapAlloc( GetProcessHeap(), 0, cbBuf*2);
629 if (buffer == NULL) return ;
631 res = GetPrinterDriverDirectoryA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded);
632 ok( res, "expected result != 0, got %d\n", res);
633 ok( cbBuf == pcbNeeded, "pcbNeeded set to %ld instead of %ld\n",
636 res = GetPrinterDriverDirectoryA(NULL, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
637 ok( res, "expected result != 0, got %d\n", res);
638 ok( cbBuf == pcbNeeded, "pcbNeeded set to %ld instead of %ld\n",
641 SetLastError(MAGIC_DEAD);
642 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, buffer, cbBuf-1, &pcbNeeded);
643 ok( !res , "expected result == 0, got %d\n", res);
644 ok( cbBuf == pcbNeeded, "pcbNeeded set to %ld instead of %ld\n",
647 ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
648 "last error set to %ld instead of ERROR_INSUFFICIENT_BUFFER\n",
652 Do not add the next test:
653 XPsp2: crash in this app, when the spooler is not running
654 NT3.5: ERROR_INVALID_USER_BUFFER
655 win9x: ERROR_INVALID_PARAMETER
657 pcbNeeded = MAGIC_DEAD;
658 SetLastError(MAGIC_DEAD);
659 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, &pcbNeeded);
662 SetLastError(MAGIC_DEAD);
663 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, buffer, cbBuf, NULL);
664 ok( (!res && RPC_X_NULL_REF_POINTER == GetLastError()) || res,
665 "expected either result == 0 and "
666 "last error == RPC_X_NULL_REF_POINTER or result != 0 "
667 "got result %d and last error == %ld\n", res, GetLastError());
669 SetLastError(MAGIC_DEAD);
670 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
671 ok(res || (GetLastError() == RPC_X_NULL_REF_POINTER),
672 "returned %d with %ld (expected '!=0' or '0' with " \
673 "RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
676 /* with a valid buffer, but level is too large */
678 SetLastError(MAGIC_DEAD);
679 res = GetPrinterDriverDirectoryA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded);
681 /* Level not checked in win9x and wine:*/
682 if((res != FALSE) && buffer[0])
684 trace("Level '2' not checked '%s'\n", buffer);
688 ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
689 "returned %d with lasterror=%ld (expected '0' with " \
690 "ERROR_INVALID_LEVEL)\n", res, GetLastError());
693 /* printing environments are case insensitive */
694 /* "Windows 4.0" is valid for win9x and NT */
696 SetLastError(MAGIC_DEAD);
697 res = GetPrinterDriverDirectoryA(NULL, env_win9x_case, 1,
698 buffer, cbBuf*2, &pcbNeeded);
700 if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
702 buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, cbBuf*2);
703 if (buffer == NULL) return ;
705 SetLastError(MAGIC_DEAD);
706 res = GetPrinterDriverDirectoryA(NULL, env_win9x_case, 1,
707 buffer, cbBuf*2, &pcbNeeded);
710 ok(res && buffer[0], "returned %d with " \
711 "lasterror=%ld and len=%d (expected '1' with 'len > 0')\n",
712 res, GetLastError(), lstrlenA((char *)buffer));
715 SetLastError(MAGIC_DEAD);
716 res = GetPrinterDriverDirectoryA(NULL, env_x86, 1,
717 buffer, cbBuf*2, &pcbNeeded);
719 if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
721 buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, cbBuf*2);
722 if (buffer == NULL) return ;
725 SetLastError(MAGIC_DEAD);
726 res = GetPrinterDriverDirectoryA(NULL, env_x86, 1,
727 buffer, cbBuf*2, &pcbNeeded);
730 /* "Windows NT x86" is invalid for win9x */
731 ok( (res && buffer[0]) ||
732 (!res && (GetLastError() == ERROR_INVALID_ENVIRONMENT)),
733 "returned %d with lasterror=%ld and len=%d (expected '!= 0' with " \
734 "'len > 0' or '0' with ERROR_INVALID_ENVIRONMENT)\n",
735 res, GetLastError(), lstrlenA((char *)buffer));
737 /* A Setup-Programm (PDFCreator_0.8.0) use empty strings */
738 SetLastError(MAGIC_DEAD);
739 res = GetPrinterDriverDirectoryA("", "", 1, buffer, cbBuf*2, &pcbNeeded);
740 ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
742 SetLastError(MAGIC_DEAD);
743 res = GetPrinterDriverDirectoryA(NULL, "", 1, buffer, cbBuf*2, &pcbNeeded);
744 ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
746 SetLastError(MAGIC_DEAD);
747 res = GetPrinterDriverDirectoryA("", NULL, 1, buffer, cbBuf*2, &pcbNeeded);
748 ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
750 HeapFree( GetProcessHeap(), 0, buffer);
753 static void test_OpenPrinter(void)
755 PRINTER_DEFAULTSA defaults;
757 LPSTR default_printer;
760 CHAR buffer[DEFAULT_PRINTER_SIZE];
763 SetLastError(MAGIC_DEAD);
764 res = OpenPrinter(NULL, NULL, NULL);
765 /* The deactivated Spooler is catched here on NT3.51 */
766 RETURN_ON_DEACTIVATED_SPOOLER(res)
767 ok(!res && (GetLastError() == ERROR_INVALID_PARAMETER),
768 "returned %ld with %ld (expected '0' with ERROR_INVALID_PARAMETER)\n",
769 res, GetLastError());
772 /* Get Handle for the local Printserver (NT only)*/
773 hprinter = (HANDLE) MAGIC_DEAD;
774 SetLastError(MAGIC_DEAD);
775 res = OpenPrinter(NULL, &hprinter, NULL);
776 /* The deactivated Spooler is catched here on XPsp2 */
777 RETURN_ON_DEACTIVATED_SPOOLER(res)
778 ok(res || (!res && GetLastError() == ERROR_INVALID_PARAMETER),
779 "returned %ld with %ld (expected '!=0' or '0' with ERROR_INVALID_PARAMETER)\n",
780 res, GetLastError());
782 ClosePrinter(hprinter);
784 defaults.pDatatype=NULL;
785 defaults.pDevMode=NULL;
787 defaults.DesiredAccess=0;
788 hprinter = (HANDLE) MAGIC_DEAD;
789 SetLastError(MAGIC_DEAD);
790 res = OpenPrinter(NULL, &hprinter, &defaults);
791 ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
792 if (res) ClosePrinter(hprinter);
794 defaults.DesiredAccess=-1;
795 hprinter = (HANDLE) MAGIC_DEAD;
796 SetLastError(MAGIC_DEAD);
797 res = OpenPrinter(NULL, &hprinter, &defaults);
799 ok(!res && GetLastError() == ERROR_ACCESS_DENIED,
800 "returned %ld with %ld (expected '0' with ERROR_ACCESS_DENIED)\n",
801 res, GetLastError());
803 if (res) ClosePrinter(hprinter);
807 size = sizeof(buffer) - 3 ;
813 if (GetComputerNameA(ptr, &size)) {
815 hprinter = (HANDLE) MAGIC_DEAD;
816 SetLastError(MAGIC_DEAD);
817 res = OpenPrinter(buffer, &hprinter, NULL);
819 ok(res || (!res && GetLastError() == ERROR_INVALID_PARAMETER),
820 "returned %ld with %ld (expected '!=0' or '0' with ERROR_INVALID_PARAMETER)\n",
821 res, GetLastError());
823 if(res) ClosePrinter(hprinter);
826 /* Invalid Printername */
827 hprinter = (HANDLE) MAGIC_DEAD;
828 SetLastError(MAGIC_DEAD);
829 res = OpenPrinter("illegal,name", &hprinter, NULL);
830 ok(!res && ((GetLastError() == ERROR_INVALID_PRINTER_NAME) ||
831 (GetLastError() == ERROR_INVALID_PARAMETER) ),
832 "returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or" \
833 "ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
834 if(res) ClosePrinter(hprinter);
836 hprinter = (HANDLE) MAGIC_DEAD;
837 SetLastError(MAGIC_DEAD);
838 res = OpenPrinter("", &hprinter, NULL);
839 /* NT: ERROR_INVALID_PRINTER_NAME, 9x: ERROR_INVALID_PARAMETER */
841 ((GetLastError() == ERROR_INVALID_PRINTER_NAME) ||
842 (GetLastError() == ERROR_INVALID_PARAMETER) ),
843 "returned %ld with %ld (expected '0' with: ERROR_INVALID_PRINTER_NAME" \
844 " or ERROR_INVALID_PARAMETER)\n", res, GetLastError());
845 if(res) ClosePrinter(hprinter);
848 /* Get Handle for the default Printer */
849 if ((default_printer = find_default_printer()))
851 hprinter = (HANDLE) MAGIC_DEAD;
852 SetLastError(MAGIC_DEAD);
853 res = OpenPrinter(default_printer, &hprinter, NULL);
854 if((!res) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE))
856 trace("The Service 'Spooler' is required for '%s'\n", default_printer);
859 ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
860 if(res) ClosePrinter(hprinter);
862 SetLastError(MAGIC_DEAD);
863 res = OpenPrinter(default_printer, NULL, NULL);
864 /* NT: FALSE with ERROR_INVALID_PARAMETER, 9x: TRUE */
865 ok(res || (GetLastError() == ERROR_INVALID_PARAMETER),
866 "returned %ld with %ld (expected '!=0' or '0' with " \
867 "ERROR_INVALID_PARAMETER)\n", res, GetLastError());
869 defaults.pDatatype=NULL;
870 defaults.pDevMode=NULL;
871 defaults.DesiredAccess=0;
873 hprinter = (HANDLE) MAGIC_DEAD;
874 SetLastError(MAGIC_DEAD);
875 res = OpenPrinter(default_printer, &hprinter, &defaults);
876 ok(res || GetLastError() == ERROR_ACCESS_DENIED,
877 "returned %ld with %ld (expected '!=0' or '0' with " \
878 "ERROR_ACCESS_DENIED)\n", res, GetLastError());
879 if(res) ClosePrinter(hprinter);
881 defaults.pDatatype="";
883 hprinter = (HANDLE) MAGIC_DEAD;
884 SetLastError(MAGIC_DEAD);
885 res = OpenPrinter(default_printer, &hprinter, &defaults);
886 /* stop here, when a remote Printserver has no RPC-Service running */
887 RETURN_ON_DEACTIVATED_SPOOLER(res)
888 ok(res || ((GetLastError() == ERROR_INVALID_DATATYPE) ||
889 (GetLastError() == ERROR_ACCESS_DENIED)),
890 "returned %ld with %ld (expected '!=0' or '0' with: " \
891 "ERROR_INVALID_DATATYPE or ERROR_ACCESS_DENIED)\n",
892 res, GetLastError());
893 if(res) ClosePrinter(hprinter);
896 defaults.pDatatype=NULL;
897 defaults.DesiredAccess=PRINTER_ACCESS_USE;
899 hprinter = (HANDLE) MAGIC_DEAD;
900 SetLastError(MAGIC_DEAD);
901 res = OpenPrinter(default_printer, &hprinter, &defaults);
902 ok(res || GetLastError() == ERROR_ACCESS_DENIED,
903 "returned %ld with %ld (expected '!=0' or '0' with " \
904 "ERROR_ACCESS_DENIED)\n", res, GetLastError());
905 if(res) ClosePrinter(hprinter);
908 defaults.DesiredAccess=PRINTER_ALL_ACCESS;
909 hprinter = (HANDLE) MAGIC_DEAD;
910 SetLastError(MAGIC_DEAD);
911 res = OpenPrinter(default_printer, &hprinter, &defaults);
912 ok(res || GetLastError() == ERROR_ACCESS_DENIED,
913 "returned %ld with %ld (expected '!=0' or '0' with " \
914 "ERROR_ACCESS_DENIED)\n", res, GetLastError());
915 if(res) ClosePrinter(hprinter);
921 static void test_SetDefaultPrinter(void)
924 LPSTR default_printer;
925 DWORD size = DEFAULT_PRINTER_SIZE;
926 CHAR buffer[DEFAULT_PRINTER_SIZE];
927 CHAR org_value[DEFAULT_PRINTER_SIZE];
930 if (!pSetDefaultPrinterA) return;
931 /* only supported on win2k and above */
933 default_printer = find_default_printer();
935 /* backup the original value */
937 SetLastError(MAGIC_DEAD);
938 res = GetProfileStringA("windows", "device", NULL, org_value, size);
940 /* first part: with the default Printer */
941 SetLastError(MAGIC_DEAD);
942 res = pSetDefaultPrinterA("no_printer_with_this_name");
944 RETURN_ON_DEACTIVATED_SPOOLER(res)
945 /* spooler is running or we have no spooler here*/
947 /* Not implemented in wine */
948 if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) {
949 trace("SetDefaultPrinterA() not implemented yet.\n");
953 ok(!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME),
954 "returned %ld with %ld (expected '0' with " \
955 "ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
957 WriteProfileStringA("windows", "device", org_value);
958 SetLastError(MAGIC_DEAD);
959 res = pSetDefaultPrinterA("");
960 ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
961 "returned %ld with %ld (expected '!=0' or '0' with " \
962 "ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
964 WriteProfileStringA("windows", "device", org_value);
965 SetLastError(MAGIC_DEAD);
966 res = pSetDefaultPrinterA(NULL);
967 ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
968 "returned %ld with %ld (expected '!=0' or '0' with " \
969 "ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
971 WriteProfileStringA("windows", "device", org_value);
972 SetLastError(MAGIC_DEAD);
973 res = pSetDefaultPrinterA(default_printer);
974 ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
975 "returned %ld with %ld (expected '!=0' or '0' with " \
976 "ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
979 /* second part: always without a default Printer */
980 WriteProfileStringA("windows", "device", NULL);
981 SetLastError(MAGIC_DEAD);
982 res = pSetDefaultPrinterA("no_printer_with_this_name");
984 ok(!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME),
985 "returned %ld with %ld (expected '0' with " \
986 "ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
988 WriteProfileStringA("windows", "device", NULL);
989 SetLastError(MAGIC_DEAD);
990 res = pSetDefaultPrinterA("");
991 /* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
992 ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
993 "returned %ld with %ld (expected '!=0' or '0' with " \
994 "ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
996 WriteProfileStringA("windows", "device", NULL);
997 SetLastError(MAGIC_DEAD);
998 res = pSetDefaultPrinterA(NULL);
999 /* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
1000 ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
1001 "returned %ld with %ld (expected '!=0' or '0' with " \
1002 "ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
1004 WriteProfileStringA("windows", "device", NULL);
1005 SetLastError(MAGIC_DEAD);
1006 res = pSetDefaultPrinterA(default_printer);
1007 ok(res || (!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME)),
1008 "returned %ld with %ld (expected '!=0' or '0' with " \
1009 "ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
1011 /* restore the original value */
1012 res = pSetDefaultPrinterA(default_printer); /* the nice way */
1013 WriteProfileStringA("windows", "device", org_value); /* the old way */
1016 SetLastError(MAGIC_DEAD);
1017 res = GetProfileStringA("windows", "device", NULL, buffer, size);
1018 ok(!lstrcmpA(org_value, buffer), "'%s' (expected '%s')\n", buffer, org_value);
1022 static void test_GetPrinterDriver(void)
1024 LPSTR default_printer;
1029 DWORD needed, filled;
1031 default_printer = find_default_printer();
1032 if (!default_printer)
1034 trace("There is no default printer installed, skiping the test\n");
1039 ret = OpenPrinter(default_printer, &hprn, NULL);
1042 trace("There is no printers installed, skiping the test\n");
1045 ok(hprn != 0, "wrong hprn %p\n", hprn);
1047 for (level = -1; level <= 7; level++)
1049 SetLastError(0xdeadbeef);
1051 ret = GetPrinterDriver(hprn, NULL, level, NULL, 0, &needed);
1052 ok(!ret, "level %d: GetPrinterDriver should fail\n", level);
1053 if (level >= 1 && level <= 6)
1055 /* Not all levels are supported on all Windows-Versions */
1056 if(GetLastError() == ERROR_INVALID_LEVEL) continue;
1057 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %ld\n", GetLastError());
1058 ok(needed > 0,"not expected needed buffer size %ld\n", needed);
1062 /* ERROR_OUTOFMEMORY found on win9x */
1063 ok( ((GetLastError() == ERROR_INVALID_LEVEL) ||
1064 (GetLastError() == ERROR_OUTOFMEMORY)),
1065 "%d: returned %d with %ld (expected '0' with: " \
1066 "ERROR_INVALID_LEVEL or ERROR_OUTOFMEMORY)\n",
1067 level, ret, GetLastError());
1068 /* needed is modified in win9x. The modified Value depends on the
1069 default Printer. testing for "needed == (DWORD)-1" will fail */
1073 buf = HeapAlloc(GetProcessHeap(), 0, needed);
1075 SetLastError(0xdeadbeef);
1077 ret = GetPrinterDriver(hprn, NULL, level, buf, needed, &filled);
1078 ok(ret, "level %d: GetPrinterDriver error %ld\n", level, GetLastError());
1079 ok(needed == filled, "needed %ld != filled %ld\n", needed, filled);
1083 DRIVER_INFO_2 *di_2 = (DRIVER_INFO_2 *)buf;
1084 DWORD calculated = sizeof(*di_2);
1086 /* MSDN is wrong: The Drivers on the win9x-CD's have cVersion=0x0400
1087 NT351: 1, NT4.0+w2k(Kernelmode): 2, w2k and above(Usermode): 3 */
1088 ok((di_2->cVersion >= 0 && di_2->cVersion <= 3) ||
1089 (di_2->cVersion == 0x0400), "di_2->cVersion = %ld\n", di_2->cVersion);
1090 ok(di_2->pName != NULL, "not expected NULL ptr\n");
1091 ok(di_2->pEnvironment != NULL, "not expected NULL ptr\n");
1092 ok(di_2->pDriverPath != NULL, "not expected NULL ptr\n");
1093 ok(di_2->pDataFile != NULL, "not expected NULL ptr\n");
1094 ok(di_2->pConfigFile != NULL, "not expected NULL ptr\n");
1096 trace("cVersion %ld\n", di_2->cVersion);
1097 trace("pName %s\n", di_2->pName);
1098 calculated += strlen(di_2->pName) + 1;
1099 trace("pEnvironment %s\n", di_2->pEnvironment);
1100 calculated += strlen(di_2->pEnvironment) + 1;
1101 trace("pDriverPath %s\n", di_2->pDriverPath);
1102 calculated += strlen(di_2->pDriverPath) + 1;
1103 trace("pDataFile %s\n", di_2->pDataFile);
1104 calculated += strlen(di_2->pDataFile) + 1;
1105 trace("pConfigFile %s\n", di_2->pConfigFile);
1106 calculated += strlen(di_2->pConfigFile) + 1;
1108 /* XP allocates memory for both ANSI and unicode names */
1109 ok(filled >= calculated,"calculated %ld != filled %ld\n", calculated, filled);
1112 HeapFree(GetProcessHeap(), 0, buf);
1115 SetLastError(0xdeadbeef);
1116 ret = ClosePrinter(hprn);
1117 ok(ret, "ClosePrinter error %ld\n", GetLastError());
1120 static void test_DEVMODE(const DEVMODE *dm, LONG dmSize, LPCSTR exp_prn_name)
1122 /* On NT3.51, some fields in DEVMODE are empty/zero
1123 (dmDeviceName, dmSpecVersion, dmDriverVersion and dmDriverExtra)
1124 We skip the Tests on this Platform */
1125 if (dm->dmSpecVersion || dm->dmDriverVersion || dm->dmDriverExtra) {
1126 /* The 0-terminated Printername can be larger (MAX_PATH) than CCHDEVICENAME */
1127 ok(!strncmp(exp_prn_name, (LPCSTR)dm->dmDeviceName, CCHDEVICENAME -1),
1128 "expected '%s', got '%s'\n", exp_prn_name, dm->dmDeviceName);
1129 ok(dm->dmSize + dm->dmDriverExtra == dmSize,
1130 "%u != %ld\n", dm->dmSize + dm->dmDriverExtra, dmSize);
1132 trace("dmFields %08lx\n", dm->dmFields);
1135 static void test_DocumentProperties(void)
1137 LPSTR default_printer;
1142 default_printer = find_default_printer();
1143 if (!default_printer)
1145 trace("There is no default printer installed, skiping the test\n");
1150 ret = OpenPrinter(default_printer, &hprn, NULL);
1153 trace("There is no printers installed, skiping the test\n");
1156 ok(hprn != 0, "wrong hprn %p\n", hprn);
1158 dm_size = DocumentProperties(0, hprn, NULL, NULL, NULL, 0);
1159 trace("DEVMODE required size %ld\n", dm_size);
1160 ok(dm_size >= sizeof(DEVMODE), "unexpected DocumentProperties ret value %ld\n", dm_size);
1162 dm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dm_size);
1164 ret = DocumentProperties(0, hprn, NULL, dm, dm, DM_OUT_BUFFER);
1165 ok(ret == IDOK, "DocumentProperties ret value %ld != expected IDOK\n", ret);
1167 test_DEVMODE(dm, dm_size, default_printer);
1169 HeapFree(GetProcessHeap(), 0, dm);
1171 SetLastError(0xdeadbeef);
1172 ret = ClosePrinter(hprn);
1173 ok(ret, "ClosePrinter error %ld\n", GetLastError());
1178 hwinspool = GetModuleHandleA("winspool.drv");
1179 pGetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterA");
1180 pSetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterA");
1182 find_default_printer();
1185 test_DeleteMonitor();
1186 test_DocumentProperties();
1187 test_EnumMonitors();
1188 test_GetDefaultPrinter();
1189 test_GetPrinterDriverDirectory();
1191 test_GetPrinterDriver();
1192 test_SetDefaultPrinter();