winspool/tests: Add tests for EnumMonitors.
[wine/multimedia.git] / dlls / winspool / tests / info.c
blobbc049344e65c58cf6e5bf524f99c666084a5d0bb
1 /*
2 * Copyright (C) 2003, 2004 Stefan Leichter
3 * Copyright (C) 2005 Detlef Riekenberg
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <stdarg.h>
22 #include "wine/test.h"
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "wingdi.h"
27 #include "winreg.h"
28 #include "winspool.h"
30 #define MAGIC_DEAD 0x00dead00
31 #define DEFAULT_PRINTER_SIZE 1000
33 static char env_x86[] = "Windows NT x86";
34 static char env_win9x_case[] = "windowS 4.0";
36 static HANDLE hwinspool;
37 static FARPROC pGetDefaultPrinterA;
39 /* report common behavior only once */
40 static DWORD report_deactivated_spooler = 1;
41 #define RETURN_ON_DEACTIVATED_SPOOLER(res) \
42 if((res == 0) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE)) \
43 { \
44 if(report_deactivated_spooler > 0) { \
45 report_deactivated_spooler--; \
46 trace("The Service 'Spooler' is required for many test\n"); \
47 } \
48 return; \
52 static LPSTR find_default_printer(VOID)
54 static LPSTR default_printer = NULL;
55 static char buffer[DEFAULT_PRINTER_SIZE];
56 DWORD needed;
57 DWORD res;
58 LPSTR ptr;
60 if ((default_printer == NULL) && (pGetDefaultPrinterA))
62 /* w2k and above */
63 needed = sizeof(buffer);
64 res = pGetDefaultPrinterA(buffer, &needed);
65 if(res) default_printer = buffer;
66 trace("default_printer: '%s'\n", default_printer);
68 if (default_printer == NULL)
70 HKEY hwindows;
71 DWORD type;
72 /* NT 3.x and above */
73 if (RegOpenKeyEx(HKEY_CURRENT_USER,
74 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows",
75 0, KEY_QUERY_VALUE, &hwindows) == NO_ERROR) {
77 needed = sizeof(buffer);
78 if (RegQueryValueEx(hwindows, "device", NULL,
79 &type, (LPBYTE)buffer, &needed) == NO_ERROR) {
81 ptr = strchr(buffer, ',');
82 if (ptr) {
83 ptr[0] = '\0';
84 default_printer = buffer;
87 RegCloseKey(hwindows);
89 trace("default_printer: '%s'\n", default_printer);
91 if (default_printer == NULL)
93 /* win9x */
94 needed = sizeof(buffer);
95 res = GetProfileStringA("windows", "device", "*", buffer, needed);
96 if(res) {
97 ptr = strchr(buffer, ',');
98 if (ptr) {
99 ptr[0] = '\0';
100 default_printer = buffer;
103 trace("default_printer: '%s'\n", default_printer);
105 return default_printer;
108 /* ########################### */
110 static void test_EnumMonitors(void)
112 DWORD res;
113 LPBYTE buffer;
114 DWORD cbBuf;
115 DWORD pcbNeeded;
116 DWORD pcReturned;
117 DWORD level;
119 /* valid levels are 1 and 2 */
120 for(level = 0; level < 4; level++) {
121 cbBuf = MAGIC_DEAD;
122 pcReturned = MAGIC_DEAD;
123 SetLastError(MAGIC_DEAD);
124 res = EnumMonitorsA(NULL, level, NULL, 0, &cbBuf, &pcReturned);
126 RETURN_ON_DEACTIVATED_SPOOLER(res)
128 /* not implemented yet in wine */
129 if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
132 /* use only a short test, when we test with an invalid level */
133 if(!level || (level > 2)) {
134 ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
135 (res && (pcReturned == 0)),
136 "(%ld) returned %ld with %ld and 0x%08lx (expected '0' with " \
137 "ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
138 level, res, GetLastError(), pcReturned);
139 continue;
142 /* Level 2 is not supported on win9x */
143 if (!res && (GetLastError() == ERROR_INVALID_LEVEL)) {
144 trace("Level %ld not supported, skipping tests\n", level);
145 continue;
148 ok((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
149 "(%ld) returned %ld with %ld (expected '0' with " \
150 "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
152 if (!cbBuf) {
153 trace("no valid buffer size returned, skipping tests\n");
154 continue;
157 buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
158 if (buffer == NULL) continue;
160 SetLastError(MAGIC_DEAD);
161 pcbNeeded = MAGIC_DEAD;
162 res = EnumMonitorsA(NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
163 ok(res, "(%ld) returned %ld with %ld (expected '!=0')\n",
164 level, res, GetLastError());
165 ok(pcbNeeded == cbBuf, "(%ld) returned %ld (expected %ld)\n",
166 level, pcbNeeded, cbBuf);
167 /* We can validate the returned Data with the Registry here */
170 SetLastError(MAGIC_DEAD);
171 pcReturned = MAGIC_DEAD;
172 pcbNeeded = MAGIC_DEAD;
173 res = EnumMonitorsA(NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
174 ok(res, "(%ld) returned %ld with %ld (expected '!=0')\n", level,
175 res, GetLastError());
176 ok(pcbNeeded == cbBuf, "(%ld) returned %ld (expected %ld)\n", level,
177 pcbNeeded, cbBuf);
179 SetLastError(MAGIC_DEAD);
180 pcbNeeded = MAGIC_DEAD;
181 res = EnumMonitorsA(NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
182 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
183 "(%ld) returned %ld with %ld (expected '0' with " \
184 "ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
186 ok(pcbNeeded == cbBuf, "(%ld) returned %ld (expected %ld)\n", level,
187 pcbNeeded, cbBuf);
190 Do not add the next test:
191 w2k+: RPC_X_NULL_REF_POINTER
192 NT3.5: ERROR_INVALID_USER_BUFFER
193 win9x: crash in winspool.drv
195 res = EnumMonitorsA(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
198 SetLastError(MAGIC_DEAD);
199 pcbNeeded = MAGIC_DEAD;
200 pcReturned = MAGIC_DEAD;
201 res = EnumMonitorsA(NULL, level, buffer, cbBuf, NULL, &pcReturned);
202 ok( res || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)) ,
203 "(%ld) returned %ld with %ld (expected '!=0' or '0' with "\
204 "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
206 pcbNeeded = MAGIC_DEAD;
207 pcReturned = MAGIC_DEAD;
208 SetLastError(MAGIC_DEAD);
209 res = EnumMonitorsA(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
210 ok( res || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)) ,
211 "(%ld) returned %ld with %ld (expected '!=0' or '0' with "\
212 "RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
214 HeapFree(GetProcessHeap(), 0, buffer);
215 } /* for(level ... */
219 static void test_GetDefaultPrinter(void)
221 BOOL retval;
222 DWORD exact = DEFAULT_PRINTER_SIZE;
223 DWORD size;
224 char buffer[DEFAULT_PRINTER_SIZE];
226 if (!pGetDefaultPrinterA) return;
227 /* only supported on NT like OSes starting with win2k */
229 SetLastError(ERROR_SUCCESS);
230 retval = pGetDefaultPrinterA(buffer, &exact);
231 if (!retval || !exact || !strlen(buffer) ||
232 (ERROR_SUCCESS != GetLastError())) {
233 if ((ERROR_FILE_NOT_FOUND == GetLastError()) ||
234 (ERROR_INVALID_NAME == GetLastError()))
235 trace("this test requires a default printer to be set\n");
236 else {
237 ok( 0, "function call GetDefaultPrinterA failed unexpected!\n"
238 "function returned %s\n"
239 "last error 0x%08lx\n"
240 "returned buffer size 0x%08lx\n"
241 "returned buffer content %s\n",
242 retval ? "true" : "false", GetLastError(), exact, buffer);
244 return;
246 SetLastError(ERROR_SUCCESS);
247 retval = pGetDefaultPrinterA(NULL, NULL);
248 ok( !retval, "function result wrong! False expected\n");
249 ok( ERROR_INVALID_PARAMETER == GetLastError(),
250 "Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08lx\n",
251 GetLastError());
253 SetLastError(ERROR_SUCCESS);
254 retval = pGetDefaultPrinterA(buffer, NULL);
255 ok( !retval, "function result wrong! False expected\n");
256 ok( ERROR_INVALID_PARAMETER == GetLastError(),
257 "Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08lx\n",
258 GetLastError());
260 SetLastError(ERROR_SUCCESS);
261 size = 0;
262 retval = pGetDefaultPrinterA(NULL, &size);
263 ok( !retval, "function result wrong! False expected\n");
264 ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
265 "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08lx\n",
266 GetLastError());
267 ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
268 exact, size);
270 SetLastError(ERROR_SUCCESS);
271 size = DEFAULT_PRINTER_SIZE;
272 retval = pGetDefaultPrinterA(NULL, &size);
273 ok( !retval, "function result wrong! False expected\n");
274 ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
275 "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08lx\n",
276 GetLastError());
277 ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
278 exact, size);
280 size = 0;
281 retval = pGetDefaultPrinterA(buffer, &size);
282 ok( !retval, "function result wrong! False expected\n");
283 ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
284 "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08lx\n",
285 GetLastError());
286 ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
287 exact, size);
289 size = exact;
290 retval = pGetDefaultPrinterA(buffer, &size);
291 ok( retval, "function result wrong! True expected\n");
292 ok( size == exact, "Parameter size wrong! %ld expected got %ld\n",
293 exact, size);
296 static void test_GetPrinterDriverDirectory(void)
298 LPBYTE buffer = NULL;
299 DWORD cbBuf = 0, pcbNeeded = 0;
300 BOOL res;
302 SetLastError(MAGIC_DEAD);
303 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, 0, &cbBuf);
304 trace("first call returned 0x%04x, with %ld: buffer size 0x%08lx\n",
305 res, GetLastError(), cbBuf);
307 RETURN_ON_DEACTIVATED_SPOOLER(res)
308 ok((res == 0) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
309 "returned %d with lasterror=%ld (expected '0' with " \
310 "ERROR_INSUFFICIENT_BUFFER)\n", res, GetLastError());
312 if (!cbBuf) {
313 trace("no valid buffer size returned, skipping tests\n");
314 return;
317 buffer = HeapAlloc( GetProcessHeap(), 0, cbBuf*2);
318 if (buffer == NULL) return ;
320 res = GetPrinterDriverDirectoryA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded);
321 ok( res, "expected result != 0, got %d\n", res);
322 ok( cbBuf == pcbNeeded, "pcbNeeded set to %ld instead of %ld\n",
323 pcbNeeded, cbBuf);
325 res = GetPrinterDriverDirectoryA(NULL, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
326 ok( res, "expected result != 0, got %d\n", res);
327 ok( cbBuf == pcbNeeded, "pcbNeeded set to %ld instead of %ld\n",
328 pcbNeeded, cbBuf);
330 SetLastError(MAGIC_DEAD);
331 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, buffer, cbBuf-1, &pcbNeeded);
332 ok( !res , "expected result == 0, got %d\n", res);
333 ok( cbBuf == pcbNeeded, "pcbNeeded set to %ld instead of %ld\n",
334 pcbNeeded, cbBuf);
336 ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
337 "last error set to %ld instead of ERROR_INSUFFICIENT_BUFFER\n",
338 GetLastError());
341 Do not add the next test:
342 XPsp2: crash in this app, when the spooler is not running
343 NT3.5: ERROR_INVALID_USER_BUFFER
344 win9x: ERROR_INVALID_PARAMETER
346 pcbNeeded = MAGIC_DEAD;
347 SetLastError(MAGIC_DEAD);
348 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, &pcbNeeded);
351 SetLastError(MAGIC_DEAD);
352 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, buffer, cbBuf, NULL);
353 ok( (!res && RPC_X_NULL_REF_POINTER == GetLastError()) || res,
354 "expected either result == 0 and "
355 "last error == RPC_X_NULL_REF_POINTER or result != 0 "
356 "got result %d and last error == %ld\n", res, GetLastError());
358 SetLastError(MAGIC_DEAD);
359 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
360 ok(res || (GetLastError() == RPC_X_NULL_REF_POINTER),
361 "returned %d with %ld (expected '!=0' or '0' with " \
362 "RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
365 /* with a valid buffer, but level is too large */
366 buffer[0] = '\0';
367 SetLastError(MAGIC_DEAD);
368 res = GetPrinterDriverDirectoryA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded);
370 /* Level not checked in win9x and wine:*/
371 if((res != FALSE) && buffer[0])
373 trace("Level '2' not checked '%s'\n", buffer);
375 else
377 ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
378 "returned %d with lasterror=%ld (expected '0' with " \
379 "ERROR_INVALID_LEVEL)\n", res, GetLastError());
382 /* printing environments are case insensitive */
383 /* "Windows 4.0" is valid for win9x and NT */
384 buffer[0] = '\0';
385 SetLastError(MAGIC_DEAD);
386 res = GetPrinterDriverDirectoryA(NULL, env_win9x_case, 1,
387 buffer, cbBuf*2, &pcbNeeded);
389 if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
390 cbBuf = pcbNeeded;
391 buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, cbBuf*2);
392 if (buffer == NULL) return ;
394 SetLastError(MAGIC_DEAD);
395 res = GetPrinterDriverDirectoryA(NULL, env_win9x_case, 1,
396 buffer, cbBuf*2, &pcbNeeded);
399 ok(res && buffer[0], "returned %d with " \
400 "lasterror=%ld and len=%d (expected '1' with 'len > 0')\n",
401 res, GetLastError(), lstrlenA((char *)buffer));
403 buffer[0] = '\0';
404 SetLastError(MAGIC_DEAD);
405 res = GetPrinterDriverDirectoryA(NULL, env_x86, 1,
406 buffer, cbBuf*2, &pcbNeeded);
408 if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
409 cbBuf = pcbNeeded;
410 buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, cbBuf*2);
411 if (buffer == NULL) return ;
413 buffer[0] = '\0';
414 SetLastError(MAGIC_DEAD);
415 res = GetPrinterDriverDirectoryA(NULL, env_x86, 1,
416 buffer, cbBuf*2, &pcbNeeded);
419 /* "Windows NT x86" is invalid for win9x */
420 ok( (res && buffer[0]) ||
421 (!res && (GetLastError() == ERROR_INVALID_ENVIRONMENT)),
422 "returned %d with lasterror=%ld and len=%d (expected '!= 0' with " \
423 "'len > 0' or '0' with ERROR_INVALID_ENVIRONMENT)\n",
424 res, GetLastError(), lstrlenA((char *)buffer));
426 /* A Setup-Programm (PDFCreator_0.8.0) use empty strings */
427 SetLastError(MAGIC_DEAD);
428 res = GetPrinterDriverDirectoryA("", "", 1, buffer, cbBuf*2, &pcbNeeded);
429 ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
431 SetLastError(MAGIC_DEAD);
432 res = GetPrinterDriverDirectoryA(NULL, "", 1, buffer, cbBuf*2, &pcbNeeded);
433 ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
435 SetLastError(MAGIC_DEAD);
436 res = GetPrinterDriverDirectoryA("", NULL, 1, buffer, cbBuf*2, &pcbNeeded);
437 ok(res, "returned %d with %ld (expected '!=0')\n", res, GetLastError() );
439 HeapFree( GetProcessHeap(), 0, buffer);
442 static void test_OpenPrinter(void)
444 PRINTER_DEFAULTSA defaults;
445 HANDLE hprinter;
446 LPSTR default_printer;
447 DWORD res;
448 DWORD size;
449 CHAR buffer[DEFAULT_PRINTER_SIZE];
450 LPSTR ptr;
452 SetLastError(MAGIC_DEAD);
453 res = OpenPrinter(NULL, NULL, NULL);
454 /* The deactivated Spooler is catched here on NT3.51 */
455 RETURN_ON_DEACTIVATED_SPOOLER(res)
456 ok(!res && (GetLastError() == ERROR_INVALID_PARAMETER),
457 "returned %ld with %ld (expected '0' with ERROR_INVALID_PARAMETER)\n",
458 res, GetLastError());
461 /* Get Handle for the local Printserver (NT only)*/
462 hprinter = (HANDLE) MAGIC_DEAD;
463 SetLastError(MAGIC_DEAD);
464 res = OpenPrinter(NULL, &hprinter, NULL);
465 /* The deactivated Spooler is catched here on XPsp2 */
466 RETURN_ON_DEACTIVATED_SPOOLER(res)
467 ok(res || (!res && GetLastError() == ERROR_INVALID_PARAMETER),
468 "returned %ld with %ld (expected '!=0' or '0' with ERROR_INVALID_PARAMETER)\n",
469 res, GetLastError());
470 if(res) {
471 ClosePrinter(hprinter);
473 defaults.pDatatype=NULL;
474 defaults.pDevMode=NULL;
476 defaults.DesiredAccess=0;
477 hprinter = (HANDLE) MAGIC_DEAD;
478 SetLastError(MAGIC_DEAD);
479 res = OpenPrinter(NULL, &hprinter, &defaults);
480 ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
481 if (res) ClosePrinter(hprinter);
483 defaults.DesiredAccess=-1;
484 hprinter = (HANDLE) MAGIC_DEAD;
485 SetLastError(MAGIC_DEAD);
486 res = OpenPrinter(NULL, &hprinter, &defaults);
487 ok(!res && GetLastError() == ERROR_ACCESS_DENIED,
488 "returned %ld with %ld (expected '0' with ERROR_ACCESS_DENIED)\n",
489 res, GetLastError());
490 if (res) ClosePrinter(hprinter);
494 size = sizeof(buffer) - 3 ;
495 ptr = buffer;
496 ptr[0] = '\\';
497 ptr++;
498 ptr[0] = '\\';
499 ptr++;
500 if (GetComputerNameA(ptr, &size)) {
502 hprinter = (HANDLE) MAGIC_DEAD;
503 SetLastError(MAGIC_DEAD);
504 res = OpenPrinter(buffer, &hprinter, NULL);
505 todo_wine {
506 ok(res || (!res && GetLastError() == ERROR_INVALID_PARAMETER),
507 "returned %ld with %ld (expected '!=0' or '0' with ERROR_INVALID_PARAMETER)\n",
508 res, GetLastError());
510 if(res) ClosePrinter(hprinter);
513 /* Invalid Printername */
514 hprinter = (HANDLE) MAGIC_DEAD;
515 SetLastError(MAGIC_DEAD);
516 res = OpenPrinter("illegal,name", &hprinter, NULL);
517 ok(!res && ((GetLastError() == ERROR_INVALID_PRINTER_NAME) ||
518 (GetLastError() == ERROR_INVALID_PARAMETER) ),
519 "returned %ld with %ld (expected '0' with: ERROR_INVALID_PARAMETER or" \
520 "ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
521 if(res) ClosePrinter(hprinter);
524 /* Get Handle for the default Printer */
525 if ((default_printer = find_default_printer()))
527 hprinter = (HANDLE) MAGIC_DEAD;
528 SetLastError(MAGIC_DEAD);
529 res = OpenPrinter(default_printer, &hprinter, NULL);
530 if((!res) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE))
532 trace("The Service 'Spooler' is required for '%s'\n", default_printer);
533 return;
535 ok(res, "returned %ld with %ld (expected '!=0')\n", res, GetLastError());
536 if(res) ClosePrinter(hprinter);
538 defaults.pDatatype=NULL;
539 defaults.pDevMode=NULL;
540 defaults.DesiredAccess=0;
542 hprinter = (HANDLE) MAGIC_DEAD;
543 SetLastError(MAGIC_DEAD);
544 res = OpenPrinter(default_printer, &hprinter, &defaults);
545 ok(res || GetLastError() == ERROR_ACCESS_DENIED,
546 "returned %ld with %ld (expected '!=0' or '0' with " \
547 "ERROR_ACCESS_DENIED)\n", res, GetLastError());
548 if(res) ClosePrinter(hprinter);
550 defaults.pDatatype="";
552 hprinter = (HANDLE) MAGIC_DEAD;
553 SetLastError(MAGIC_DEAD);
554 res = OpenPrinter(default_printer, &hprinter, &defaults);
555 ok(res || ((GetLastError() == ERROR_INVALID_DATATYPE) ||
556 (GetLastError() == ERROR_ACCESS_DENIED)),
557 "returned %ld with %ld (expected '!=0' or '0' with: " \
558 "ERROR_INVALID_DATATYPE or ERROR_ACCESS_DENIED)\n",
559 res, GetLastError());
560 if(res) ClosePrinter(hprinter);
563 defaults.pDatatype=NULL;
564 defaults.DesiredAccess=PRINTER_ACCESS_USE;
566 hprinter = (HANDLE) MAGIC_DEAD;
567 SetLastError(MAGIC_DEAD);
568 res = OpenPrinter(default_printer, &hprinter, &defaults);
569 ok(res || GetLastError() == ERROR_ACCESS_DENIED,
570 "returned %ld with %ld (expected '!=0' or '0' with " \
571 "ERROR_ACCESS_DENIED)\n", res, GetLastError());
572 if(res) ClosePrinter(hprinter);
575 defaults.DesiredAccess=PRINTER_ALL_ACCESS;
576 hprinter = (HANDLE) MAGIC_DEAD;
577 SetLastError(MAGIC_DEAD);
578 res = OpenPrinter(default_printer, &hprinter, &defaults);
579 ok(res || GetLastError() == ERROR_ACCESS_DENIED,
580 "returned %ld with %ld (expected '!=0' or '0' with " \
581 "ERROR_ACCESS_DENIED)\n", res, GetLastError());
582 if(res) ClosePrinter(hprinter);
587 START_TEST(info)
589 hwinspool = GetModuleHandleA("winspool.drv");
590 pGetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterA");
592 find_default_printer();
594 test_EnumMonitors();
595 test_GetDefaultPrinter();
596 test_GetPrinterDriverDirectory();
597 test_OpenPrinter();