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
24 #define NONAMELESSSTRUCT
25 #define NONAMELESSUNION
36 #include "wine/test.h"
38 #define MAGIC_DEAD 0xdeadbeef
39 #define DEFAULT_PRINTER_SIZE 1000
41 static CHAR does_not_exist_dll
[]= "does_not_exist.dll";
42 static CHAR does_not_exist
[] = "does_not_exist";
43 static CHAR empty
[] = "";
44 static CHAR env_x86
[] = "Windows NT x86";
45 static CHAR env_win9x_case
[] = "windowS 4.0";
46 static CHAR illegal_name
[] = "illegal,name";
47 static CHAR invalid_env
[] = "invalid_env";
48 static CHAR portname_com1
[] = "COM1:";
49 static CHAR portname_file
[] = "FILE:";
50 static CHAR portname_lpt1
[] = "LPT1:";
51 static CHAR server_does_not_exist
[] = "\\does_not_exist";
52 static CHAR version_dll
[] = "version.dll";
53 static CHAR winetest
[] = "winetest";
54 static CHAR xcv_localport
[] = ",XcvMonitor Local Port";
56 static WCHAR cmd_MonitorUIW
[] = {'M','o','n','i','t','o','r','U','I',0};
57 static WCHAR cmd_PortIsValidW
[] = {'P','o','r','t','I','s','V','a','l','i','d',0};
58 static WCHAR emptyW
[] = {0};
60 static WCHAR portname_com1W
[] = {'C','O','M','1',':',0};
61 static WCHAR portname_com2W
[] = {'C','O','M','2',':',0};
62 static WCHAR portname_fileW
[] = {'F','I','L','E',':',0};
63 static WCHAR portname_lpt1W
[] = {'L','P','T','1',':',0};
64 static WCHAR portname_lpt2W
[] = {'L','P','T','2',':',0};
66 static HANDLE hwinspool
;
67 static FARPROC pGetDefaultPrinterA
;
68 static FARPROC pSetDefaultPrinterA
;
69 static DWORD (WINAPI
* pXcvDataW
)(HANDLE
, LPCWSTR
, PBYTE
, DWORD
, PBYTE
, DWORD
, PDWORD
, PDWORD
);
72 /* ################################ */
74 struct monitor_entry
{
79 static LPSTR default_printer
= NULL
;
80 static LPSTR local_server
= NULL
;
81 static LPSTR tempdirA
= NULL
;
82 static LPSTR tempfileA
= NULL
;
83 static LPWSTR tempdirW
= NULL
;
84 static LPWSTR tempfileW
= NULL
;
86 /* ################################ */
87 /* report common behavior only once */
88 static DWORD report_deactivated_spooler
= 1;
89 #define RETURN_ON_DEACTIVATED_SPOOLER(res) \
90 if((res == 0) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE)) \
92 if(report_deactivated_spooler > 0) { \
93 report_deactivated_spooler--; \
94 skip("The Service 'Spooler' is required for many test\n"); \
100 static void find_default_printer(VOID
)
102 static char buffer
[DEFAULT_PRINTER_SIZE
];
107 if ((default_printer
== NULL
) && (pGetDefaultPrinterA
))
110 needed
= sizeof(buffer
);
111 res
= pGetDefaultPrinterA(buffer
, &needed
);
112 if(res
) default_printer
= buffer
;
113 trace("default_printer: '%s'\n", default_printer
);
115 if (default_printer
== NULL
)
119 /* NT 3.x and above */
120 if (RegOpenKeyEx(HKEY_CURRENT_USER
,
121 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows",
122 0, KEY_QUERY_VALUE
, &hwindows
) == NO_ERROR
) {
124 needed
= sizeof(buffer
);
125 if (RegQueryValueEx(hwindows
, "device", NULL
,
126 &type
, (LPBYTE
)buffer
, &needed
) == NO_ERROR
) {
128 ptr
= strchr(buffer
, ',');
131 default_printer
= buffer
;
134 RegCloseKey(hwindows
);
136 trace("default_printer: '%s'\n", default_printer
);
138 if (default_printer
== NULL
)
141 needed
= sizeof(buffer
);
142 res
= GetProfileStringA("windows", "device", "*", buffer
, needed
);
144 ptr
= strchr(buffer
, ',');
147 default_printer
= buffer
;
150 trace("default_printer: '%s'\n", default_printer
);
155 static struct monitor_entry
* find_installed_monitor(void)
157 MONITOR_INFO_2A mi2a
;
158 static struct monitor_entry
* entry
= NULL
;
162 static struct monitor_entry monitor_table
[] = {
163 {env_win9x_case
, "localspl.dll"},
164 {env_x86
, "localspl.dll"},
165 {env_win9x_case
, "localmon.dll"},
166 {env_x86
, "localmon.dll"},
167 {env_win9x_case
, "tcpmon.dll"},
168 {env_x86
, "tcpmon.dll"},
169 {env_win9x_case
, "usbmon.dll"},
170 {env_x86
, "usbmon.dll"},
171 {env_win9x_case
, "mspp32.dll"},
172 {env_x86
, "win32spl.dll"},
173 {env_x86
, "redmonnt.dll"},
174 {env_x86
, "redmon35.dll"},
175 {env_win9x_case
, "redmon95.dll"},
176 {env_x86
, "pdfcmnnt.dll"},
177 {env_win9x_case
, "pdfcmn95.dll"},
180 if (entry
) return entry
;
182 num_tests
= (sizeof(monitor_table
)/sizeof(struct monitor_entry
));
185 DeleteMonitorA(NULL
, env_x86
, winetest
);
186 DeleteMonitorA(NULL
, env_win9x_case
, winetest
);
188 /* find a usable monitor from the table */
189 mi2a
.pName
= winetest
;
190 while ((entry
== NULL
) && (i
< num_tests
)) {
191 entry
= &monitor_table
[i
];
193 mi2a
.pEnvironment
= entry
->env
;
194 mi2a
.pDLLName
= entry
->dllname
;
196 if (AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
)) {
198 trace("using '%s', '%s'\n", entry
->env
, entry
->dllname
);
199 DeleteMonitorA(NULL
, entry
->env
, winetest
);
210 /* ########################### */
212 static void find_local_server(VOID
)
214 static char buffer
[MAX_PATH
];
218 size
= sizeof(buffer
) - 3 ;
223 SetLastError(0xdeadbeef);
224 res
= GetComputerNameA(&buffer
[2], &size
);
225 trace("returned %d with %d and %d: '%s'\n", res
, GetLastError(), size
, buffer
);
227 ok( res
!= 0, "returned %d with %d and %d: '%s' (expected '!= 0')\n",
228 res
, GetLastError(), size
, buffer
);
230 if (res
) local_server
= buffer
;
233 /* ########################### */
235 static void find_tempfile(VOID
)
237 static CHAR buffer_dirA
[MAX_PATH
];
238 static CHAR buffer_fileA
[MAX_PATH
];
239 static WCHAR buffer_dirW
[MAX_PATH
];
240 static WCHAR buffer_fileW
[MAX_PATH
];
244 memset(buffer_dirA
, 0, MAX_PATH
- 1);
245 buffer_dirA
[MAX_PATH
- 1] = '\0';
246 SetLastError(0xdeadbeef);
247 res
= GetTempPathA(MAX_PATH
, buffer_dirA
);
248 ok(res
, "returned %u with %u and '%s' (expected '!= 0')\n", res
, GetLastError(), buffer_dirA
);
249 if (res
== 0) return;
251 memset(buffer_fileA
, 0, MAX_PATH
- 1);
252 buffer_fileA
[MAX_PATH
- 1] = '\0';
253 SetLastError(0xdeadbeef);
254 res
= GetTempFileNameA(buffer_dirA
, winetest
, 0, buffer_fileA
);
255 ok(res
, "returned %u with %u and '%s' (expected '!= 0')\n", res
, GetLastError(), buffer_fileA
);
256 if (res
== 0) return;
258 SetLastError(0xdeadbeef);
259 resint
= MultiByteToWideChar(CP_ACP
, 0, buffer_dirA
, -1, buffer_dirW
, MAX_PATH
);
260 ok(res
, "returned %u with %u (expected '!= 0')\n", resint
, GetLastError());
261 if (resint
== 0) return;
263 SetLastError(0xdeadbeef);
264 resint
= MultiByteToWideChar(CP_ACP
, 0, buffer_fileA
, -1, buffer_fileW
, MAX_PATH
);
265 ok(res
, "returned %u with %u (expected '!= 0')\n", resint
, GetLastError());
266 if (resint
== 0) return;
268 tempdirA
= buffer_dirA
;
269 tempfileA
= buffer_fileA
;
270 tempdirW
= buffer_dirW
;
271 tempfileW
= buffer_fileW
;
272 trace("tempfile: '%s'\n", tempfileA
);
275 /* ########################### */
277 static void test_AddMonitor(void)
279 MONITOR_INFO_2A mi2a
;
280 struct monitor_entry
* entry
= NULL
;
283 entry
= find_installed_monitor();
285 SetLastError(MAGIC_DEAD
);
286 res
= AddMonitorA(NULL
, 1, NULL
);
287 ok(!res
&& (GetLastError() == ERROR_INVALID_LEVEL
),
288 "returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
289 res
, GetLastError());
291 SetLastError(MAGIC_DEAD
);
292 res
= AddMonitorA(NULL
, 3, NULL
);
293 ok(!res
&& (GetLastError() == ERROR_INVALID_LEVEL
),
294 "returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
295 res
, GetLastError());
299 /* This test crash with win9x on vmware (works with win9x on qemu 0.8.1) */
300 SetLastError(MAGIC_DEAD
);
301 res
= AddMonitorA(NULL
, 2, NULL
);
302 /* NT: unchanged, 9x: ERROR_PRIVILEGE_NOT_HELD */
304 ((GetLastError() == MAGIC_DEAD
) ||
305 (GetLastError() == ERROR_PRIVILEGE_NOT_HELD
)),
306 "returned %d with %d (expected '0' with: MAGIC_DEAD or "
307 "ERROR_PRIVILEGE_NOT_HELD)\n", res
, GetLastError());
310 ZeroMemory(&mi2a
, sizeof(MONITOR_INFO_2A
));
311 SetLastError(MAGIC_DEAD
);
312 res
= AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
313 RETURN_ON_DEACTIVATED_SPOOLER(res
)
315 if (!res
&& (GetLastError() == ERROR_ACCESS_DENIED
)) {
316 skip("(ACCESS_DENIED)\n");
320 /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_INVALID_ENVIRONMENT */
321 ok(!res
&& ((GetLastError() == ERROR_INVALID_PARAMETER
) ||
322 (GetLastError() == ERROR_INVALID_ENVIRONMENT
)),
323 "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
324 "ERROR_INVALID_ENVIRONMENT)\n", res
, GetLastError());
327 skip("No usable Monitor found\n");
333 /* The Test is deactivated, because when mi2a.pName is NULL, the subkey
334 HKLM\System\CurrentControlSet\Control\Print\Monitors\C:\WINDOWS\SYSTEM
335 or HKLM\System\CurrentControlSet\Control\Print\Monitors\ì
336 is created on win9x and we do not want to hit this bug here. */
338 mi2a
.pEnvironment
= entry
->env
;
339 SetLastError(MAGIC_DEAD
);
340 res
= AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
341 /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
344 mi2a
.pEnvironment
= entry
->env
;
346 SetLastError(MAGIC_DEAD
);
347 res
= AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
348 /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
350 ((GetLastError() == ERROR_INVALID_PARAMETER
) ||
351 (GetLastError() == ERROR_PRIVILEGE_NOT_HELD
)),
352 "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
353 "ERROR_PRIVILEGE_NOT_HELD)\n",
354 res
, GetLastError());
356 mi2a
.pName
= winetest
;
357 SetLastError(MAGIC_DEAD
);
358 res
= AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
359 /* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
361 ((GetLastError() == ERROR_INVALID_PARAMETER
) ||
362 (GetLastError() == ERROR_PRIVILEGE_NOT_HELD
)),
363 "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
364 "ERROR_PRIVILEGE_NOT_HELD)\n",
365 res
, GetLastError());
367 mi2a
.pDLLName
= empty
;
368 SetLastError(MAGIC_DEAD
);
369 res
= AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
370 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
371 "returned %d with %d (expected '0' with ERROR_INVALID_PARAMETER)\n",
372 res
, GetLastError());
374 mi2a
.pDLLName
= does_not_exist_dll
;
375 SetLastError(MAGIC_DEAD
);
376 res
= AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
377 /* NT: ERROR_MOD_NOT_FOUND, 9x: ERROR_INVALID_PARAMETER */
379 ((GetLastError() == ERROR_MOD_NOT_FOUND
) ||
380 (GetLastError() == ERROR_INVALID_PARAMETER
)),
381 "returned %d with %d (expected '0' with: ERROR_MOD_NOT_FOUND or "
382 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
384 mi2a
.pDLLName
= version_dll
;
385 SetLastError(MAGIC_DEAD
);
386 res
= AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
387 /* NT: ERROR_PROC_NOT_FOUND, 9x: ERROR_INVALID_PARAMETER */
389 ((GetLastError() == ERROR_PROC_NOT_FOUND
) ||
390 (GetLastError() == ERROR_INVALID_PARAMETER
)),
391 "returned %d with %d (expected '0' with: ERROR_PROC_NOT_FOUND or "
392 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
393 if (res
) DeleteMonitorA(NULL
, entry
->env
, winetest
);
395 /* Test AddMonitor with real options */
396 mi2a
.pDLLName
= entry
->dllname
;
397 SetLastError(MAGIC_DEAD
);
398 res
= AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
399 ok(res
, "returned %d with %d (expected '!= 0')\n", res
, GetLastError());
401 /* add a monitor twice */
402 SetLastError(MAGIC_DEAD
);
403 res
= AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
404 /* NT: ERROR_PRINT_MONITOR_ALREADY_INSTALLED (3006), 9x: ERROR_ALREADY_EXISTS (183) */
406 ((GetLastError() == ERROR_PRINT_MONITOR_ALREADY_INSTALLED
) ||
407 (GetLastError() == ERROR_ALREADY_EXISTS
)),
408 "returned %d with %d (expected '0' with: "
409 "ERROR_PRINT_MONITOR_ALREADY_INSTALLED or ERROR_ALREADY_EXISTS)\n",
410 res
, GetLastError());
412 DeleteMonitorA(NULL
, entry
->env
, winetest
);
413 SetLastError(MAGIC_DEAD
);
414 res
= AddMonitorA(empty
, 2, (LPBYTE
) &mi2a
);
415 ok(res
, "returned %d with %d (expected '!= 0')\n", res
, GetLastError());
418 DeleteMonitorA(NULL
, entry
->env
, winetest
);
422 /* ########################### */
424 static void test_AddPort(void)
428 SetLastError(0xdeadbeef);
429 res
= AddPortA(NULL
, 0, NULL
);
430 RETURN_ON_DEACTIVATED_SPOOLER(res
)
431 /* NT: RPC_X_NULL_REF_POINTER, 9x: ERROR_INVALID_PARAMETER */
432 ok( !res
&& ((GetLastError() == RPC_X_NULL_REF_POINTER
) ||
433 (GetLastError() == ERROR_INVALID_PARAMETER
)),
434 "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
435 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
438 SetLastError(0xdeadbeef);
439 res
= AddPortA(NULL
, 0, empty
);
440 /* Allowed only for (Printer-)Administrators */
441 if (!res
&& (GetLastError() == ERROR_ACCESS_DENIED
)) {
442 skip("(ACCESS_DENIED)\n");
445 /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
446 ok( !res
&& ((GetLastError() == ERROR_NOT_SUPPORTED
) ||
447 (GetLastError() == ERROR_INVALID_PARAMETER
)),
448 "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
449 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
452 SetLastError(0xdeadbeef);
453 res
= AddPortA(NULL
, 0, does_not_exist
);
454 /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
455 ok( !res
&& ((GetLastError() == ERROR_NOT_SUPPORTED
) ||
456 (GetLastError() == ERROR_INVALID_PARAMETER
)),
457 "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
458 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
462 /* ########################### */
464 static void test_ConfigurePort(void)
469 SetLastError(0xdeadbeef);
470 res
= ConfigurePortA(NULL
, 0, NULL
);
471 RETURN_ON_DEACTIVATED_SPOOLER(res
)
472 /* NT: RPC_X_NULL_REF_POINTER, 9x: ERROR_INVALID_PARAMETER */
473 ok( !res
&& ((GetLastError() == RPC_X_NULL_REF_POINTER
) ||
474 (GetLastError() == ERROR_INVALID_PARAMETER
)),
475 "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
476 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
478 SetLastError(0xdeadbeef);
479 res
= ConfigurePortA(NULL
, 0, empty
);
480 /* Allowed only for (Printer-)Administrators */
481 if (!res
&& (GetLastError() == ERROR_ACCESS_DENIED
)) {
482 skip("(ACCESS_DENIED)\n");
485 /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
486 ok( !res
&& ((GetLastError() == ERROR_NOT_SUPPORTED
) ||
487 (GetLastError() == ERROR_INVALID_PARAMETER
)),
488 "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
489 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
492 SetLastError(0xdeadbeef);
493 res
= ConfigurePortA(NULL
, 0, does_not_exist
);
494 /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
495 ok( !res
&& ((GetLastError() == ERROR_NOT_SUPPORTED
) ||
496 (GetLastError() == ERROR_INVALID_PARAMETER
)),
497 "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
498 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
502 - Case of Portnames is ignored
503 - Portname without ":" => NT: ERROR_NOT_SUPPORTED, 9x: Dialog comes up
504 - Empty Servername (LPT1:) => NT: ERROR_NOT_SUPPORTED, 9x: Dialog comes up
506 - Port not present => 9x: ERROR_INVALID_PARAMETER, NT:ERROR_NOT_SUPPORTED
507 - "FILE:" => 9x:Success, NT:ERROR_CANCELED
508 - Cancel ("Local Port") => ERROR_CANCELED
509 - Cancel ("Redirected Port") => Success
511 if (winetest_interactive
> 0) {
512 SetLastError(0xdeadbeef);
513 res
= ConfigurePortA(NULL
, 0, portname_com1
);
514 trace("'%s' returned %d with %d\n", portname_com1
, res
, GetLastError());
516 SetLastError(0xdeadbeef);
517 res
= ConfigurePortA(NULL
, 0, portname_lpt1
);
518 trace("'%s' returned %d with %d\n", portname_lpt1
, res
, GetLastError());
520 SetLastError(0xdeadbeef);
521 res
= ConfigurePortA(NULL
, 0, portname_file
);
522 trace("'%s' returned %d with %d\n", portname_file
, res
, GetLastError());
526 /* ########################### */
528 static void test_DeleteMonitor(void)
530 MONITOR_INFO_2A mi2a
;
531 struct monitor_entry
* entry
= NULL
;
535 entry
= find_installed_monitor();
538 skip("No usable Monitor found\n");
542 mi2a
.pName
= winetest
;
543 mi2a
.pEnvironment
= entry
->env
;
544 mi2a
.pDLLName
= entry
->dllname
;
546 /* Testing DeleteMonitor with real options */
547 AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
549 SetLastError(MAGIC_DEAD
);
550 res
= DeleteMonitorA(NULL
, entry
->env
, winetest
);
551 ok(res
, "returned %d with %d (expected '!= 0')\n", res
, GetLastError());
553 /* Delete the Monitor twice */
554 SetLastError(MAGIC_DEAD
);
555 res
= DeleteMonitorA(NULL
, entry
->env
, winetest
);
556 /* NT: ERROR_UNKNOWN_PRINT_MONITOR (3000), 9x: ERROR_INVALID_PARAMETER (87) */
558 ((GetLastError() == ERROR_UNKNOWN_PRINT_MONITOR
) ||
559 (GetLastError() == ERROR_INVALID_PARAMETER
)),
560 "returned %d with %d (expected '0' with: ERROR_UNKNOWN_PRINT_MONITOR"
561 " or ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
563 /* the environment */
564 AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
565 SetLastError(MAGIC_DEAD
);
566 res
= DeleteMonitorA(NULL
, NULL
, winetest
);
567 ok(res
, "returned %d with %d (expected '!=0')\n", res
, GetLastError());
569 AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
570 SetLastError(MAGIC_DEAD
);
571 res
= DeleteMonitorA(NULL
, empty
, winetest
);
572 ok(res
, "returned %d with %d (expected '!=0')\n", res
, GetLastError());
574 AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
575 SetLastError(MAGIC_DEAD
);
576 res
= DeleteMonitorA(NULL
, invalid_env
, winetest
);
577 ok(res
, "returned %d with %d (expected '!=0')\n", res
, GetLastError());
579 /* the monitor-name */
580 AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
581 SetLastError(MAGIC_DEAD
);
582 res
= DeleteMonitorA(NULL
, entry
->env
, NULL
);
583 /* NT: ERROR_INVALID_PARAMETER (87), 9x: ERROR_INVALID_NAME (123)*/
585 ((GetLastError() == ERROR_INVALID_PARAMETER
) ||
586 (GetLastError() == ERROR_INVALID_NAME
)),
587 "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
588 "ERROR_INVALID_NAME)\n", res
, GetLastError());
590 AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
591 SetLastError(MAGIC_DEAD
);
592 res
= DeleteMonitorA(NULL
, entry
->env
, empty
);
593 /* NT: ERROR_INVALID_PARAMETER (87), 9x: ERROR_INVALID_NAME (123)*/
595 ((GetLastError() == ERROR_INVALID_PARAMETER
) ||
596 (GetLastError() == ERROR_INVALID_NAME
)),
597 "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
598 "ERROR_INVALID_NAME)\n", res
, GetLastError());
600 AddMonitorA(NULL
, 2, (LPBYTE
) &mi2a
);
601 SetLastError(MAGIC_DEAD
);
602 res
= DeleteMonitorA(empty
, entry
->env
, winetest
);
603 ok(res
, "returned %d with %d (expected '!=0')\n", res
, GetLastError());
606 DeleteMonitorA(NULL
, entry
->env
, winetest
);
609 /* ########################### */
611 static void test_DeletePort(void)
615 SetLastError(0xdeadbeef);
616 res
= DeletePortA(NULL
, 0, NULL
);
617 RETURN_ON_DEACTIVATED_SPOOLER(res
)
619 SetLastError(0xdeadbeef);
620 res
= DeletePortA(NULL
, 0, empty
);
621 /* Allowed only for (Printer-)Administrators */
622 if (!res
&& (GetLastError() == ERROR_ACCESS_DENIED
)) {
623 skip("(ACCESS_DENIED)\n");
626 /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
627 ok( !res
&& ((GetLastError() == ERROR_NOT_SUPPORTED
) ||
628 (GetLastError() == ERROR_INVALID_PARAMETER
)),
629 "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
630 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
633 SetLastError(0xdeadbeef);
634 res
= DeletePortA(NULL
, 0, does_not_exist
);
635 /* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
636 ok( !res
&& ((GetLastError() == ERROR_NOT_SUPPORTED
) ||
637 (GetLastError() == ERROR_INVALID_PARAMETER
)),
638 "returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
639 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
643 /* ########################### */
645 static void test_EnumForms(LPSTR pName
)
656 res
= OpenPrinter(pName
, &hprinter
, NULL
);
657 RETURN_ON_DEACTIVATED_SPOOLER(res
)
658 if (!res
|| !hprinter
)
660 /* Open the local Prinserver is not supported on win9x */
661 if (pName
) skip("Failed to open '%s' (not supported on win9x)\n", pName
);
665 /* valid levels are 1 and 2 */
666 for(level
= 0; level
< 4; level
++) {
668 pcReturned
= 0xdeadbeef;
669 SetLastError(0xdeadbeef);
670 res
= EnumFormsA(hprinter
, level
, NULL
, 0, &cbBuf
, &pcReturned
);
672 /* EnumForms is not implemented in win9x */
673 if (!res
&& (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)) continue;
675 /* EnumForms for the Server not implemented on all NT-Versions */
676 if (!res
&& (GetLastError() == ERROR_INVALID_HANDLE
) && !pName
) continue;
678 /* Level 2 for EnumForms is not supported on all systems */
679 if (!res
&& (GetLastError() == ERROR_INVALID_LEVEL
) && (level
== 2)) continue;
681 /* use only a short test, when we test with an invalid level */
682 if(!level
|| (level
> 2)) {
683 ok( (!res
&& (GetLastError() == ERROR_INVALID_LEVEL
)) ||
684 (res
&& (pcReturned
== 0)),
685 "(%d) returned %d with %d and 0x%08x (expected '0' with "
686 "ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
687 level
, res
, GetLastError(), pcReturned
);
691 ok((!res
) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
692 "(%d) returned %d with %d (expected '0' with "
693 "ERROR_INSUFFICIENT_BUFFER)\n", level
, res
, GetLastError());
695 buffer
= HeapAlloc(GetProcessHeap(), 0, cbBuf
*2);
696 if (buffer
== NULL
) continue;
698 SetLastError(0xdeadbeef);
699 res
= EnumFormsA(hprinter
, level
, buffer
, cbBuf
, &pcbNeeded
, &pcReturned
);
700 ok(res
, "(%d) returned %d with %d (expected '!=0')\n",
701 level
, res
, GetLastError());
702 /* We can dump the returned Data here */
705 SetLastError(0xdeadbeef);
706 res
= EnumFormsA(hprinter
, level
, buffer
, cbBuf
+1, &pcbNeeded
, &pcReturned
);
707 ok( res
, "(%d) returned %d with %d (expected '!=0')\n",
708 level
, res
, GetLastError());
710 SetLastError(0xdeadbeef);
711 res
= EnumFormsA(hprinter
, level
, buffer
, cbBuf
-1, &pcbNeeded
, &pcReturned
);
712 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
713 "(%d) returned %d with %d (expected '0' with "
714 "ERROR_INSUFFICIENT_BUFFER)\n", level
, res
, GetLastError());
717 SetLastError(0xdeadbeef);
718 res
= EnumFormsA(hprinter
, level
, NULL
, cbBuf
, &pcbNeeded
, &pcReturned
);
719 ok( !res
&& (GetLastError() == ERROR_INVALID_USER_BUFFER
) ,
720 "(%d) returned %d with %d (expected '0' with "
721 "ERROR_INVALID_USER_BUFFER)\n", level
, res
, GetLastError());
724 SetLastError(0xdeadbeef);
725 res
= EnumFormsA(hprinter
, level
, buffer
, cbBuf
, NULL
, &pcReturned
);
726 ok( !res
&& (GetLastError() == RPC_X_NULL_REF_POINTER
) ,
727 "(%d) returned %d with %d (expected '0' with "
728 "RPC_X_NULL_REF_POINTER)\n", level
, res
, GetLastError());
730 SetLastError(0xdeadbeef);
731 res
= EnumFormsA(hprinter
, level
, buffer
, cbBuf
, &pcbNeeded
, NULL
);
732 ok( !res
&& (GetLastError() == RPC_X_NULL_REF_POINTER
) ,
733 "(%d) returned %d with %d (expected '0' with "
734 "RPC_X_NULL_REF_POINTER)\n", level
, res
, GetLastError());
736 SetLastError(0xdeadbeef);
737 res
= EnumFormsA(0, level
, buffer
, cbBuf
, &pcbNeeded
, &pcReturned
);
738 ok( !res
&& (GetLastError() == ERROR_INVALID_HANDLE
) ,
739 "(%d) returned %d with %d (expected '0' with "
740 "ERROR_INVALID_HANDLE)\n", level
, res
, GetLastError());
742 HeapFree(GetProcessHeap(), 0, buffer
);
743 } /* for(level ... */
745 ClosePrinter(hprinter
);
748 /* ########################### */
750 static void test_EnumMonitors(void)
759 /* valid levels are 1 and 2 */
760 for(level
= 0; level
< 4; level
++) {
762 pcReturned
= MAGIC_DEAD
;
763 SetLastError(MAGIC_DEAD
);
764 res
= EnumMonitorsA(NULL
, level
, NULL
, 0, &cbBuf
, &pcReturned
);
766 RETURN_ON_DEACTIVATED_SPOOLER(res
)
768 /* not implemented yet in wine */
769 if (!res
&& (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)) continue;
772 /* use only a short test, when we test with an invalid level */
773 if(!level
|| (level
> 2)) {
774 ok( (!res
&& (GetLastError() == ERROR_INVALID_LEVEL
)) ||
775 (res
&& (pcReturned
== 0)),
776 "(%d) returned %d with %d and 0x%08x (expected '0' with "
777 "ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
778 level
, res
, GetLastError(), pcReturned
);
782 /* Level 2 is not supported on win9x */
783 if (!res
&& (GetLastError() == ERROR_INVALID_LEVEL
)) {
784 skip("Level %d not supported\n", level
);
788 ok((!res
) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
789 "(%d) returned %d with %d (expected '0' with "
790 "ERROR_INSUFFICIENT_BUFFER)\n", level
, res
, GetLastError());
793 skip("no valid buffer size returned\n");
797 buffer
= HeapAlloc(GetProcessHeap(), 0, cbBuf
*2);
798 if (buffer
== NULL
) continue;
800 SetLastError(MAGIC_DEAD
);
801 pcbNeeded
= MAGIC_DEAD
;
802 res
= EnumMonitorsA(NULL
, level
, buffer
, cbBuf
, &pcbNeeded
, &pcReturned
);
803 ok(res
, "(%d) returned %d with %d (expected '!=0')\n",
804 level
, res
, GetLastError());
805 ok(pcbNeeded
== cbBuf
, "(%d) returned %d (expected %d)\n",
806 level
, pcbNeeded
, cbBuf
);
807 /* We can validate the returned Data with the Registry here */
810 SetLastError(MAGIC_DEAD
);
811 pcReturned
= MAGIC_DEAD
;
812 pcbNeeded
= MAGIC_DEAD
;
813 res
= EnumMonitorsA(NULL
, level
, buffer
, cbBuf
+1, &pcbNeeded
, &pcReturned
);
814 ok(res
, "(%d) returned %d with %d (expected '!=0')\n", level
,
815 res
, GetLastError());
816 ok(pcbNeeded
== cbBuf
, "(%d) returned %d (expected %d)\n", level
,
819 SetLastError(MAGIC_DEAD
);
820 pcbNeeded
= MAGIC_DEAD
;
821 res
= EnumMonitorsA(NULL
, level
, buffer
, cbBuf
-1, &pcbNeeded
, &pcReturned
);
822 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
823 "(%d) returned %d with %d (expected '0' with "
824 "ERROR_INSUFFICIENT_BUFFER)\n", level
, res
, GetLastError());
826 ok(pcbNeeded
== cbBuf
, "(%d) returned %d (expected %d)\n", level
,
830 Do not add the next test:
831 w2k+: RPC_X_NULL_REF_POINTER
832 NT3.5: ERROR_INVALID_USER_BUFFER
833 win9x: crash in winspool.drv
835 res = EnumMonitorsA(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
838 SetLastError(MAGIC_DEAD
);
839 pcbNeeded
= MAGIC_DEAD
;
840 pcReturned
= MAGIC_DEAD
;
841 res
= EnumMonitorsA(NULL
, level
, buffer
, cbBuf
, NULL
, &pcReturned
);
842 ok( res
|| (!res
&& (GetLastError() == RPC_X_NULL_REF_POINTER
)) ,
843 "(%d) returned %d with %d (expected '!=0' or '0' with "
844 "RPC_X_NULL_REF_POINTER)\n", level
, res
, GetLastError());
846 pcbNeeded
= MAGIC_DEAD
;
847 pcReturned
= MAGIC_DEAD
;
848 SetLastError(MAGIC_DEAD
);
849 res
= EnumMonitorsA(NULL
, level
, buffer
, cbBuf
, &pcbNeeded
, NULL
);
850 ok( res
|| (!res
&& (GetLastError() == RPC_X_NULL_REF_POINTER
)) ,
851 "(%d) returned %d with %d (expected '!=0' or '0' with "
852 "RPC_X_NULL_REF_POINTER)\n", level
, res
, GetLastError());
854 HeapFree(GetProcessHeap(), 0, buffer
);
855 } /* for(level ... */
858 /* ########################### */
860 static void test_EnumPorts(void)
869 /* valid levels are 1 and 2 */
870 for(level
= 0; level
< 4; level
++) {
873 pcReturned
= 0xdeadbeef;
874 SetLastError(0xdeadbeef);
875 res
= EnumPortsA(NULL
, level
, NULL
, 0, &cbBuf
, &pcReturned
);
876 RETURN_ON_DEACTIVATED_SPOOLER(res
)
878 /* use only a short test, when we test with an invalid level */
879 if(!level
|| (level
> 2)) {
880 /* NT: ERROR_INVALID_LEVEL, 9x: success */
881 ok( (!res
&& (GetLastError() == ERROR_INVALID_LEVEL
)) ||
882 (res
&& (pcReturned
== 0)),
883 "(%d) returned %d with %d and 0x%08x (expected '0' with "
884 "ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
885 level
, res
, GetLastError(), pcReturned
);
890 /* Level 2 is not supported on NT 3.x */
891 if (!res
&& (GetLastError() == ERROR_INVALID_LEVEL
)) {
892 skip("Level %d not supported\n", level
);
896 ok((!res
) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
897 "(%d) returned %d with %d (expected '0' with "
898 "ERROR_INSUFFICIENT_BUFFER)\n", level
, res
, GetLastError());
900 buffer
= HeapAlloc(GetProcessHeap(), 0, cbBuf
*2);
901 if (buffer
== NULL
) continue;
903 pcbNeeded
= 0xdeadbeef;
904 SetLastError(0xdeadbeef);
905 res
= EnumPortsA(NULL
, level
, buffer
, cbBuf
, &pcbNeeded
, &pcReturned
);
906 ok(res
, "(%d) returned %d with %d (expected '!=0')\n", level
, res
, GetLastError());
907 ok(pcbNeeded
== cbBuf
, "(%d) returned %d (expected %d)\n", level
, pcbNeeded
, cbBuf
);
908 /* ToDo: Compare the returned Data with the Registry / "win.ini",[Ports] here */
910 pcbNeeded
= 0xdeadbeef;
911 pcReturned
= 0xdeadbeef;
912 SetLastError(0xdeadbeef);
913 res
= EnumPortsA(NULL
, level
, buffer
, cbBuf
+1, &pcbNeeded
, &pcReturned
);
914 ok(res
, "(%d) returned %d with %d (expected '!=0')\n", level
, res
, GetLastError());
915 ok(pcbNeeded
== cbBuf
, "(%d) returned %d (expected %d)\n", level
, pcbNeeded
, cbBuf
);
917 pcbNeeded
= 0xdeadbeef;
918 SetLastError(0xdeadbeef);
919 res
= EnumPortsA(NULL
, level
, buffer
, cbBuf
-1, &pcbNeeded
, &pcReturned
);
920 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
921 "(%d) returned %d with %d (expected '0' with "
922 "ERROR_INSUFFICIENT_BUFFER)\n", level
, res
, GetLastError());
923 ok(pcbNeeded
== cbBuf
, "(%d) returned %d (expected %d)\n", level
, pcbNeeded
, cbBuf
);
926 Do not add this test:
927 res = EnumPortsA(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
928 w2k+: RPC_X_NULL_REF_POINTER
929 NT3.5: ERROR_INVALID_USER_BUFFER
930 win9x: crash in winspool.drv
933 SetLastError(0xdeadbeef);
934 res
= EnumPorts(NULL
, level
, buffer
, cbBuf
, NULL
, &pcReturned
);
935 /* NT: RPC_X_NULL_REF_POINTER (1780), 9x: success */
936 ok( (!res
&& (GetLastError() == RPC_X_NULL_REF_POINTER
) ) ||
937 ( res
&& (GetLastError() == ERROR_SUCCESS
) ),
938 "(%d) returned %d with %d (expected '0' with "
939 "RPC_X_NULL_REF_POINTER or '!=0' with NO_ERROR)\n",
940 level
, res
, GetLastError());
943 SetLastError(0xdeadbeef);
944 res
= EnumPorts(NULL
, level
, buffer
, cbBuf
, &pcbNeeded
, NULL
);
945 /* NT: RPC_X_NULL_REF_POINTER (1780), 9x: success */
946 ok( (!res
&& (GetLastError() == RPC_X_NULL_REF_POINTER
) ) ||
947 ( res
&& (GetLastError() == ERROR_SUCCESS
) ),
948 "(%d) returned %d with %d (expected '0' with "
949 "RPC_X_NULL_REF_POINTER or '!=0' with NO_ERROR)\n",
950 level
, res
, GetLastError());
952 HeapFree(GetProcessHeap(), 0, buffer
);
956 /* ########################### */
958 static void test_GetDefaultPrinter(void)
961 DWORD exact
= DEFAULT_PRINTER_SIZE
;
963 char buffer
[DEFAULT_PRINTER_SIZE
];
965 if (!pGetDefaultPrinterA
) return;
966 /* only supported on NT like OSes starting with win2k */
968 SetLastError(ERROR_SUCCESS
);
969 retval
= pGetDefaultPrinterA(buffer
, &exact
);
970 if (!retval
|| !exact
|| !strlen(buffer
) ||
971 (ERROR_SUCCESS
!= GetLastError())) {
972 if ((ERROR_FILE_NOT_FOUND
== GetLastError()) ||
973 (ERROR_INVALID_NAME
== GetLastError()))
974 trace("this test requires a default printer to be set\n");
976 ok( 0, "function call GetDefaultPrinterA failed unexpected!\n"
977 "function returned %s\n"
978 "last error 0x%08x\n"
979 "returned buffer size 0x%08x\n"
980 "returned buffer content %s\n",
981 retval
? "true" : "false", GetLastError(), exact
, buffer
);
985 SetLastError(ERROR_SUCCESS
);
986 retval
= pGetDefaultPrinterA(NULL
, NULL
);
987 ok( !retval
, "function result wrong! False expected\n");
988 ok( ERROR_INVALID_PARAMETER
== GetLastError(),
989 "Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08x\n",
992 SetLastError(ERROR_SUCCESS
);
993 retval
= pGetDefaultPrinterA(buffer
, NULL
);
994 ok( !retval
, "function result wrong! False expected\n");
995 ok( ERROR_INVALID_PARAMETER
== GetLastError(),
996 "Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08x\n",
999 SetLastError(ERROR_SUCCESS
);
1001 retval
= pGetDefaultPrinterA(NULL
, &size
);
1002 ok( !retval
, "function result wrong! False expected\n");
1003 ok( ERROR_INSUFFICIENT_BUFFER
== GetLastError(),
1004 "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08x\n",
1006 ok( size
== exact
, "Parameter size wrong! %d expected got %d\n",
1009 SetLastError(ERROR_SUCCESS
);
1010 size
= DEFAULT_PRINTER_SIZE
;
1011 retval
= pGetDefaultPrinterA(NULL
, &size
);
1012 ok( !retval
, "function result wrong! False expected\n");
1013 ok( ERROR_INSUFFICIENT_BUFFER
== GetLastError(),
1014 "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08x\n",
1016 ok( size
== exact
, "Parameter size wrong! %d expected got %d\n",
1020 retval
= pGetDefaultPrinterA(buffer
, &size
);
1021 ok( !retval
, "function result wrong! False expected\n");
1022 ok( ERROR_INSUFFICIENT_BUFFER
== GetLastError(),
1023 "Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08x\n",
1025 ok( size
== exact
, "Parameter size wrong! %d expected got %d\n",
1029 retval
= pGetDefaultPrinterA(buffer
, &size
);
1030 ok( retval
, "function result wrong! True expected\n");
1031 ok( size
== exact
, "Parameter size wrong! %d expected got %d\n",
1035 static void test_GetPrinterDriverDirectory(void)
1037 LPBYTE buffer
= NULL
;
1038 DWORD cbBuf
= 0, pcbNeeded
= 0;
1042 SetLastError(MAGIC_DEAD
);
1043 res
= GetPrinterDriverDirectoryA( NULL
, NULL
, 1, NULL
, 0, &cbBuf
);
1044 trace("first call returned 0x%04x, with %d: buffer size 0x%08x\n",
1045 res
, GetLastError(), cbBuf
);
1047 RETURN_ON_DEACTIVATED_SPOOLER(res
)
1048 ok((res
== 0) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
1049 "returned %d with lasterror=%d (expected '0' with "
1050 "ERROR_INSUFFICIENT_BUFFER)\n", res
, GetLastError());
1053 skip("no valid buffer size returned\n");
1057 buffer
= HeapAlloc( GetProcessHeap(), 0, cbBuf
*2);
1058 if (buffer
== NULL
) return ;
1060 res
= GetPrinterDriverDirectoryA(NULL
, NULL
, 1, buffer
, cbBuf
, &pcbNeeded
);
1061 ok( res
, "expected result != 0, got %d\n", res
);
1062 ok( cbBuf
== pcbNeeded
, "pcbNeeded set to %d instead of %d\n",
1065 res
= GetPrinterDriverDirectoryA(NULL
, NULL
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1066 ok( res
, "expected result != 0, got %d\n", res
);
1067 ok( cbBuf
== pcbNeeded
, "pcbNeeded set to %d instead of %d\n",
1070 SetLastError(MAGIC_DEAD
);
1071 res
= GetPrinterDriverDirectoryA( NULL
, NULL
, 1, buffer
, cbBuf
-1, &pcbNeeded
);
1072 ok( !res
, "expected result == 0, got %d\n", res
);
1073 ok( cbBuf
== pcbNeeded
, "pcbNeeded set to %d instead of %d\n",
1076 ok( ERROR_INSUFFICIENT_BUFFER
== GetLastError(),
1077 "last error set to %d instead of ERROR_INSUFFICIENT_BUFFER\n",
1081 Do not add the next test:
1082 XPsp2: crash in this app, when the spooler is not running
1083 NT3.5: ERROR_INVALID_USER_BUFFER
1084 win9x: ERROR_INVALID_PARAMETER
1086 pcbNeeded = MAGIC_DEAD;
1087 SetLastError(MAGIC_DEAD);
1088 res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, &pcbNeeded);
1091 SetLastError(MAGIC_DEAD
);
1092 res
= GetPrinterDriverDirectoryA( NULL
, NULL
, 1, buffer
, cbBuf
, NULL
);
1093 ok( (!res
&& RPC_X_NULL_REF_POINTER
== GetLastError()) || res
,
1094 "expected either result == 0 and "
1095 "last error == RPC_X_NULL_REF_POINTER or result != 0 "
1096 "got result %d and last error == %d\n", res
, GetLastError());
1098 SetLastError(MAGIC_DEAD
);
1099 res
= GetPrinterDriverDirectoryA( NULL
, NULL
, 1, NULL
, cbBuf
, NULL
);
1100 ok(res
|| (GetLastError() == RPC_X_NULL_REF_POINTER
),
1101 "returned %d with %d (expected '!=0' or '0' with "
1102 "RPC_X_NULL_REF_POINTER)\n", res
, GetLastError());
1105 /* with a valid buffer, but level is too large */
1107 SetLastError(MAGIC_DEAD
);
1108 res
= GetPrinterDriverDirectoryA(NULL
, NULL
, 2, buffer
, cbBuf
, &pcbNeeded
);
1110 /* Level not checked in win9x and wine:*/
1111 if((res
!= FALSE
) && buffer
[0])
1113 trace("Level '2' not checked '%s'\n", buffer
);
1117 ok( !res
&& (GetLastError() == ERROR_INVALID_LEVEL
),
1118 "returned %d with lasterror=%d (expected '0' with "
1119 "ERROR_INVALID_LEVEL)\n", res
, GetLastError());
1122 /* printing environments are case insensitive */
1123 /* "Windows 4.0" is valid for win9x and NT */
1125 SetLastError(MAGIC_DEAD
);
1126 res
= GetPrinterDriverDirectoryA(NULL
, env_win9x_case
, 1,
1127 buffer
, cbBuf
*2, &pcbNeeded
);
1129 if(!res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
)) {
1131 buffer
= HeapReAlloc(GetProcessHeap(), 0, buffer
, cbBuf
*2);
1132 if (buffer
== NULL
) return ;
1134 SetLastError(MAGIC_DEAD
);
1135 res
= GetPrinterDriverDirectoryA(NULL
, env_win9x_case
, 1,
1136 buffer
, cbBuf
*2, &pcbNeeded
);
1139 ok(res
&& buffer
[0], "returned %d with "
1140 "lasterror=%d and len=%d (expected '1' with 'len > 0')\n",
1141 res
, GetLastError(), lstrlenA((char *)buffer
));
1144 SetLastError(MAGIC_DEAD
);
1145 res
= GetPrinterDriverDirectoryA(NULL
, env_x86
, 1,
1146 buffer
, cbBuf
*2, &pcbNeeded
);
1148 if(!res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
)) {
1150 buffer
= HeapReAlloc(GetProcessHeap(), 0, buffer
, cbBuf
*2);
1151 if (buffer
== NULL
) return ;
1154 SetLastError(MAGIC_DEAD
);
1155 res
= GetPrinterDriverDirectoryA(NULL
, env_x86
, 1,
1156 buffer
, cbBuf
*2, &pcbNeeded
);
1159 /* "Windows NT x86" is invalid for win9x */
1160 ok( (res
&& buffer
[0]) ||
1161 (!res
&& (GetLastError() == ERROR_INVALID_ENVIRONMENT
)),
1162 "returned %d with lasterror=%d and len=%d (expected '!= 0' with "
1163 "'len > 0' or '0' with ERROR_INVALID_ENVIRONMENT)\n",
1164 res
, GetLastError(), lstrlenA((char *)buffer
));
1166 /* A setup program (PDFCreator_0.8.0) use empty strings */
1167 SetLastError(MAGIC_DEAD
);
1168 res
= GetPrinterDriverDirectoryA(empty
, empty
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1169 ok(res
, "returned %d with %d (expected '!=0')\n", res
, GetLastError() );
1171 SetLastError(MAGIC_DEAD
);
1172 res
= GetPrinterDriverDirectoryA(NULL
, empty
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1173 ok(res
, "returned %d with %d (expected '!=0')\n", res
, GetLastError() );
1175 SetLastError(MAGIC_DEAD
);
1176 res
= GetPrinterDriverDirectoryA(empty
, NULL
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1177 ok(res
, "returned %d with %d (expected '!=0')\n", res
, GetLastError() );
1179 HeapFree( GetProcessHeap(), 0, buffer
);
1184 static void test_GetPrintProcessorDirectory(void)
1186 LPBYTE buffer
= NULL
;
1188 DWORD pcbNeeded
= 0;
1192 SetLastError(0xdeadbeef);
1193 res
= GetPrintProcessorDirectoryA(NULL
, NULL
, 1, NULL
, 0, &cbBuf
);
1194 /* The deactivated Spooler is caught here on NT3.51 */
1195 RETURN_ON_DEACTIVATED_SPOOLER(res
)
1196 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
1197 "returned %d with %d (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
1198 res
, GetLastError());
1200 buffer
= HeapAlloc(GetProcessHeap(), 0, cbBuf
*2);
1201 if(buffer
== NULL
) return;
1204 SetLastError(0xdeadbeef);
1205 res
= GetPrintProcessorDirectoryA(NULL
, NULL
, 1, buffer
, cbBuf
, &pcbNeeded
);
1206 ok(res
, "returned %d with %d (expected '!= 0')\n", res
, GetLastError());
1208 SetLastError(0xdeadbeef);
1210 res
= GetPrintProcessorDirectoryA(NULL
, NULL
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1211 ok(res
, "returned %d with %d (expected '!= 0')\n", res
, GetLastError());
1213 /* Buffer to small */
1215 SetLastError(0xdeadbeef);
1216 res
= GetPrintProcessorDirectoryA( NULL
, NULL
, 1, buffer
, cbBuf
-1, &pcbNeeded
);
1217 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
),
1218 "returned %d with %d (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
1219 res
, GetLastError());
1223 /* XPsp2: the program will crash here, when the spooler is not running */
1224 /* GetPrinterDriverDirectory has the same bug */
1226 SetLastError(0xdeadbeef);
1227 res
= GetPrintProcessorDirectoryA( NULL
, NULL
, 1, NULL
, cbBuf
, &pcbNeeded
);
1231 SetLastError(0xdeadbeef);
1232 res
= GetPrintProcessorDirectoryA( NULL
, NULL
, 1, buffer
, cbBuf
, NULL
);
1233 /* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
1234 ok( res
|| (GetLastError() == RPC_X_NULL_REF_POINTER
),
1235 "returned %d with %d (expected '!= 0' or '0' with "
1236 "RPC_X_NULL_REF_POINTER)\n", res
, GetLastError());
1240 SetLastError(0xdeadbeef);
1241 res
= GetPrintProcessorDirectoryA( NULL
, NULL
, 1, NULL
, cbBuf
, NULL
);
1242 /* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
1243 ok( res
|| (GetLastError() == RPC_X_NULL_REF_POINTER
),
1244 "returned %d with %d (expected '!= 0' or '0' with "
1245 "RPC_X_NULL_REF_POINTER)\n", res
, GetLastError());
1248 /* with a valid buffer, but level is invalid */
1250 SetLastError(0xdeadbeef);
1251 res
= GetPrintProcessorDirectoryA(NULL
, NULL
, 2, buffer
, cbBuf
, &pcbNeeded
);
1252 if (res
&& buffer
[0])
1254 /* Level is ignored in win9x*/
1255 trace("invalid level (2) was ignored\n");
1259 ok( !res
&& (GetLastError() == ERROR_INVALID_LEVEL
),
1260 "returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
1261 res
, GetLastError());
1264 /* Empty environment is the same as the default environment */
1266 SetLastError(0xdeadbeef);
1267 res
= GetPrintProcessorDirectoryA(NULL
, empty
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1268 ok(res
, "returned %d with %d (expected '!= 0')\n", res
, GetLastError());
1270 /* "Windows 4.0" is valid for win9x and NT */
1272 SetLastError(0xdeadbeef);
1273 res
= GetPrintProcessorDirectoryA(NULL
, env_win9x_case
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1274 ok(res
, "returned %d with %d (expected '!= 0')\n", res
, GetLastError());
1277 /* "Windows NT x86" is invalid for win9x */
1279 SetLastError(0xdeadbeef);
1280 res
= GetPrintProcessorDirectoryA(NULL
, env_x86
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1281 ok( res
|| (GetLastError() == ERROR_INVALID_ENVIRONMENT
),
1282 "returned %d with %d (expected '!= 0' or '0' with "
1283 "ERROR_INVALID_ENVIRONMENT)\n", res
, GetLastError());
1285 /* invalid on all Systems */
1287 SetLastError(0xdeadbeef);
1288 res
= GetPrintProcessorDirectoryA(NULL
, invalid_env
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1289 ok( !res
&& (GetLastError() == ERROR_INVALID_ENVIRONMENT
),
1290 "returned %d with %d (expected '0' with ERROR_INVALID_ENVIRONMENT)\n",
1291 res
, GetLastError());
1293 /* Empty servername is the same as the local computer */
1295 SetLastError(0xdeadbeef);
1296 res
= GetPrintProcessorDirectoryA(empty
, NULL
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1297 ok(res
, "returned %d with %d (expected '!= 0')\n", res
, GetLastError());
1299 /* invalid on all Systems */
1301 SetLastError(0xdeadbeef);
1302 res
= GetPrintProcessorDirectoryA(server_does_not_exist
, NULL
, 1, buffer
, cbBuf
*2, &pcbNeeded
);
1303 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
1304 "returned %d with %d (expected '0' with ERROR_INVALID_PARAMETER)\n",
1305 res
, GetLastError());
1307 HeapFree(GetProcessHeap(), 0, buffer
);
1312 static void test_OpenPrinter(void)
1314 PRINTER_DEFAULTSA defaults
;
1318 SetLastError(MAGIC_DEAD
);
1319 res
= OpenPrinter(NULL
, NULL
, NULL
);
1320 /* The deactivated Spooler is caught here on NT3.51 */
1321 RETURN_ON_DEACTIVATED_SPOOLER(res
)
1322 ok(!res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
1323 "returned %d with %d (expected '0' with ERROR_INVALID_PARAMETER)\n",
1324 res
, GetLastError());
1327 /* Get Handle for the local Printserver (NT only)*/
1328 hprinter
= (HANDLE
) MAGIC_DEAD
;
1329 SetLastError(MAGIC_DEAD
);
1330 res
= OpenPrinter(NULL
, &hprinter
, NULL
);
1331 /* The deactivated Spooler is caught here on XPsp2 */
1332 RETURN_ON_DEACTIVATED_SPOOLER(res
)
1333 ok(res
|| (!res
&& GetLastError() == ERROR_INVALID_PARAMETER
),
1334 "returned %d with %d (expected '!=0' or '0' with ERROR_INVALID_PARAMETER)\n",
1335 res
, GetLastError());
1337 ClosePrinter(hprinter
);
1339 defaults
.pDatatype
=NULL
;
1340 defaults
.pDevMode
=NULL
;
1342 defaults
.DesiredAccess
=0;
1343 hprinter
= (HANDLE
) MAGIC_DEAD
;
1344 SetLastError(MAGIC_DEAD
);
1345 res
= OpenPrinter(NULL
, &hprinter
, &defaults
);
1346 ok(res
, "returned %d with %d (expected '!=0')\n", res
, GetLastError());
1347 if (res
) ClosePrinter(hprinter
);
1349 defaults
.DesiredAccess
=-1;
1350 hprinter
= (HANDLE
) MAGIC_DEAD
;
1351 SetLastError(MAGIC_DEAD
);
1352 res
= OpenPrinter(NULL
, &hprinter
, &defaults
);
1354 ok(!res
&& GetLastError() == ERROR_ACCESS_DENIED
,
1355 "returned %d with %d (expected '0' with ERROR_ACCESS_DENIED)\n",
1356 res
, GetLastError());
1358 if (res
) ClosePrinter(hprinter
);
1363 if (local_server
!= NULL
) {
1364 hprinter
= (HANDLE
) 0xdeadbeef;
1365 SetLastError(0xdeadbeef);
1366 res
= OpenPrinter(local_server
, &hprinter
, NULL
);
1367 ok(res
|| (!res
&& GetLastError() == ERROR_INVALID_PARAMETER
),
1368 "returned %d with %d (expected '!=0' or '0' with ERROR_INVALID_PARAMETER)\n",
1369 res
, GetLastError());
1370 if(res
) ClosePrinter(hprinter
);
1373 /* Invalid Printername */
1374 hprinter
= (HANDLE
) MAGIC_DEAD
;
1375 SetLastError(MAGIC_DEAD
);
1376 res
= OpenPrinter(illegal_name
, &hprinter
, NULL
);
1377 ok(!res
&& ((GetLastError() == ERROR_INVALID_PRINTER_NAME
) ||
1378 (GetLastError() == ERROR_INVALID_PARAMETER
) ),
1379 "returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or"
1380 "ERROR_INVALID_PRINTER_NAME)\n", res
, GetLastError());
1381 if(res
) ClosePrinter(hprinter
);
1383 hprinter
= (HANDLE
) MAGIC_DEAD
;
1384 SetLastError(MAGIC_DEAD
);
1385 res
= OpenPrinter(empty
, &hprinter
, NULL
);
1386 /* NT: ERROR_INVALID_PRINTER_NAME, 9x: ERROR_INVALID_PARAMETER */
1388 ((GetLastError() == ERROR_INVALID_PRINTER_NAME
) ||
1389 (GetLastError() == ERROR_INVALID_PARAMETER
) ),
1390 "returned %d with %d (expected '0' with: ERROR_INVALID_PRINTER_NAME"
1391 " or ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
1392 if(res
) ClosePrinter(hprinter
);
1395 /* Get Handle for the default Printer */
1396 if (default_printer
)
1398 hprinter
= (HANDLE
) MAGIC_DEAD
;
1399 SetLastError(MAGIC_DEAD
);
1400 res
= OpenPrinter(default_printer
, &hprinter
, NULL
);
1401 if((!res
) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE
))
1403 trace("The Service 'Spooler' is required for '%s'\n", default_printer
);
1406 ok(res
, "returned %d with %d (expected '!=0')\n", res
, GetLastError());
1407 if(res
) ClosePrinter(hprinter
);
1409 SetLastError(MAGIC_DEAD
);
1410 res
= OpenPrinter(default_printer
, NULL
, NULL
);
1411 /* NT: FALSE with ERROR_INVALID_PARAMETER, 9x: TRUE */
1412 ok(res
|| (GetLastError() == ERROR_INVALID_PARAMETER
),
1413 "returned %d with %d (expected '!=0' or '0' with "
1414 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError());
1416 defaults
.pDatatype
=NULL
;
1417 defaults
.pDevMode
=NULL
;
1418 defaults
.DesiredAccess
=0;
1420 hprinter
= (HANDLE
) MAGIC_DEAD
;
1421 SetLastError(MAGIC_DEAD
);
1422 res
= OpenPrinter(default_printer
, &hprinter
, &defaults
);
1423 ok(res
|| GetLastError() == ERROR_ACCESS_DENIED
,
1424 "returned %d with %d (expected '!=0' or '0' with "
1425 "ERROR_ACCESS_DENIED)\n", res
, GetLastError());
1426 if(res
) ClosePrinter(hprinter
);
1428 defaults
.pDatatype
= empty
;
1430 hprinter
= (HANDLE
) MAGIC_DEAD
;
1431 SetLastError(MAGIC_DEAD
);
1432 res
= OpenPrinter(default_printer
, &hprinter
, &defaults
);
1433 /* stop here, when a remote Printserver has no RPC-Service running */
1434 RETURN_ON_DEACTIVATED_SPOOLER(res
)
1435 ok(res
|| ((GetLastError() == ERROR_INVALID_DATATYPE
) ||
1436 (GetLastError() == ERROR_ACCESS_DENIED
)),
1437 "returned %d with %d (expected '!=0' or '0' with: "
1438 "ERROR_INVALID_DATATYPE or ERROR_ACCESS_DENIED)\n",
1439 res
, GetLastError());
1440 if(res
) ClosePrinter(hprinter
);
1443 defaults
.pDatatype
=NULL
;
1444 defaults
.DesiredAccess
=PRINTER_ACCESS_USE
;
1446 hprinter
= (HANDLE
) MAGIC_DEAD
;
1447 SetLastError(MAGIC_DEAD
);
1448 res
= OpenPrinter(default_printer
, &hprinter
, &defaults
);
1449 ok(res
|| GetLastError() == ERROR_ACCESS_DENIED
,
1450 "returned %d with %d (expected '!=0' or '0' with "
1451 "ERROR_ACCESS_DENIED)\n", res
, GetLastError());
1452 if(res
) ClosePrinter(hprinter
);
1455 defaults
.DesiredAccess
=PRINTER_ALL_ACCESS
;
1456 hprinter
= (HANDLE
) MAGIC_DEAD
;
1457 SetLastError(MAGIC_DEAD
);
1458 res
= OpenPrinter(default_printer
, &hprinter
, &defaults
);
1459 ok(res
|| GetLastError() == ERROR_ACCESS_DENIED
,
1460 "returned %d with %d (expected '!=0' or '0' with "
1461 "ERROR_ACCESS_DENIED)\n", res
, GetLastError());
1462 if(res
) ClosePrinter(hprinter
);
1468 static void test_SetDefaultPrinter(void)
1471 DWORD size
= DEFAULT_PRINTER_SIZE
;
1472 CHAR buffer
[DEFAULT_PRINTER_SIZE
];
1473 CHAR org_value
[DEFAULT_PRINTER_SIZE
];
1476 if (!pSetDefaultPrinterA
) return;
1477 /* only supported on win2k and above */
1479 /* backup the original value */
1480 org_value
[0] = '\0';
1481 SetLastError(MAGIC_DEAD
);
1482 res
= GetProfileStringA("windows", "device", NULL
, org_value
, size
);
1484 /* first part: with the default Printer */
1485 SetLastError(MAGIC_DEAD
);
1486 res
= pSetDefaultPrinterA("no_printer_with_this_name");
1488 RETURN_ON_DEACTIVATED_SPOOLER(res
)
1489 /* spooler is running or we have no spooler here*/
1491 /* Not implemented in wine */
1492 if (!res
&& (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)) {
1493 trace("SetDefaultPrinterA() not implemented yet.\n");
1497 ok(!res
&& (GetLastError() == ERROR_INVALID_PRINTER_NAME
),
1498 "returned %d with %d (expected '0' with "
1499 "ERROR_INVALID_PRINTER_NAME)\n", res
, GetLastError());
1501 WriteProfileStringA("windows", "device", org_value
);
1502 SetLastError(MAGIC_DEAD
);
1503 res
= pSetDefaultPrinterA("");
1504 ok(res
|| (!res
&& (GetLastError() == ERROR_INVALID_PRINTER_NAME
)),
1505 "returned %d with %d (expected '!=0' or '0' with "
1506 "ERROR_INVALID_PRINTER_NAME)\n", res
, GetLastError());
1508 WriteProfileStringA("windows", "device", org_value
);
1509 SetLastError(MAGIC_DEAD
);
1510 res
= pSetDefaultPrinterA(NULL
);
1511 ok(res
|| (!res
&& (GetLastError() == ERROR_INVALID_PRINTER_NAME
)),
1512 "returned %d with %d (expected '!=0' or '0' with "
1513 "ERROR_INVALID_PRINTER_NAME)\n", res
, GetLastError());
1515 WriteProfileStringA("windows", "device", org_value
);
1516 SetLastError(MAGIC_DEAD
);
1517 res
= pSetDefaultPrinterA(default_printer
);
1518 ok(res
|| (!res
&& (GetLastError() == ERROR_INVALID_PRINTER_NAME
)),
1519 "returned %d with %d (expected '!=0' or '0' with "
1520 "ERROR_INVALID_PRINTER_NAME)\n", res
, GetLastError());
1523 /* second part: always without a default Printer */
1524 WriteProfileStringA("windows", "device", NULL
);
1525 SetLastError(MAGIC_DEAD
);
1526 res
= pSetDefaultPrinterA("no_printer_with_this_name");
1528 ok(!res
&& (GetLastError() == ERROR_INVALID_PRINTER_NAME
),
1529 "returned %d with %d (expected '0' with "
1530 "ERROR_INVALID_PRINTER_NAME)\n", res
, GetLastError());
1532 WriteProfileStringA("windows", "device", NULL
);
1533 SetLastError(MAGIC_DEAD
);
1534 res
= pSetDefaultPrinterA("");
1535 /* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
1536 ok(res
|| (!res
&& (GetLastError() == ERROR_INVALID_PRINTER_NAME
)),
1537 "returned %d with %d (expected '!=0' or '0' with "
1538 "ERROR_INVALID_PRINTER_NAME)\n", res
, GetLastError());
1540 WriteProfileStringA("windows", "device", NULL
);
1541 SetLastError(MAGIC_DEAD
);
1542 res
= pSetDefaultPrinterA(NULL
);
1543 /* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
1544 ok(res
|| (!res
&& (GetLastError() == ERROR_INVALID_PRINTER_NAME
)),
1545 "returned %d with %d (expected '!=0' or '0' with "
1546 "ERROR_INVALID_PRINTER_NAME)\n", res
, GetLastError());
1548 WriteProfileStringA("windows", "device", NULL
);
1549 SetLastError(MAGIC_DEAD
);
1550 res
= pSetDefaultPrinterA(default_printer
);
1551 ok(res
|| (!res
&& (GetLastError() == ERROR_INVALID_PRINTER_NAME
)),
1552 "returned %d with %d (expected '!=0' or '0' with "
1553 "ERROR_INVALID_PRINTER_NAME)\n", res
, GetLastError());
1555 /* restore the original value */
1556 res
= pSetDefaultPrinterA(default_printer
); /* the nice way */
1557 WriteProfileStringA("windows", "device", org_value
); /* the old way */
1560 SetLastError(MAGIC_DEAD
);
1561 res
= GetProfileStringA("windows", "device", NULL
, buffer
, size
);
1562 ok(!lstrcmpA(org_value
, buffer
), "'%s' (expected '%s')\n", buffer
, org_value
);
1566 /* ########################### */
1568 static void test_XcvDataW_MonitorUI(void)
1572 BYTE buffer
[MAX_PATH
+ 4];
1576 PRINTER_DEFAULTSA pd
;
1578 /* api is not present before w2k */
1579 if (pXcvDataW
== NULL
) return;
1581 pd
.pDatatype
= NULL
;
1583 pd
.DesiredAccess
= SERVER_ACCESS_ADMINISTER
;
1586 SetLastError(0xdeadbeef);
1587 res
= OpenPrinter(xcv_localport
, &hXcv
, &pd
);
1588 RETURN_ON_DEACTIVATED_SPOOLER(res
)
1589 ok(res
, "returned %d with %u and handle %p (expected '!= 0')\n", res
, GetLastError(), hXcv
);
1592 /* ask for needed size */
1593 needed
= (DWORD
) 0xdeadbeef;
1594 status
= (DWORD
) 0xdeadbeef;
1595 SetLastError(0xdeadbeef);
1596 res
= pXcvDataW(hXcv
, cmd_MonitorUIW
, NULL
, 0, NULL
, 0, &needed
, &status
);
1597 ok( res
&& (status
== ERROR_INSUFFICIENT_BUFFER
) && (needed
<= MAX_PATH
),
1598 "returned %d with %u and %u for status %u (expected '!= 0' and "
1599 "'<= MAX_PATH' for status ERROR_INSUFFICIENT_BUFFER)\n",
1600 res
, GetLastError(), needed
, status
);
1602 if (needed
> MAX_PATH
) {
1604 skip("buffer overflow (%u)\n", needed
);
1607 len
= needed
; /* Size is in bytes */
1609 /* the command is required */
1610 needed
= (DWORD
) 0xdeadbeef;
1611 status
= (DWORD
) 0xdeadbeef;
1612 SetLastError(0xdeadbeef);
1613 res
= pXcvDataW(hXcv
, emptyW
, NULL
, 0, NULL
, 0, &needed
, &status
);
1614 ok( res
&& (status
== ERROR_INVALID_PARAMETER
),
1615 "returned %d with %u and %u for status %u (expected '!= 0' with "
1616 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError(), needed
, status
);
1618 needed
= (DWORD
) 0xdeadbeef;
1619 status
= (DWORD
) 0xdeadbeef;
1620 SetLastError(0xdeadbeef);
1621 res
= pXcvDataW(hXcv
, NULL
, NULL
, 0, buffer
, MAX_PATH
, &needed
, &status
);
1622 ok( !res
&& (GetLastError() == RPC_X_NULL_REF_POINTER
),
1623 "returned %d with %u and %u for status %u (expected '0' with "
1624 "RPC_X_NULL_REF_POINTER)\n", res
, GetLastError(), needed
, status
);
1626 /* "PDWORD needed" is checked before RPC-Errors */
1627 needed
= (DWORD
) 0xdeadbeef;
1628 status
= (DWORD
) 0xdeadbeef;
1629 SetLastError(0xdeadbeef);
1630 res
= pXcvDataW(hXcv
, cmd_MonitorUIW
, NULL
, 0, buffer
, len
, NULL
, &status
);
1631 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
1632 "returned %d with %u and %u for status %u (expected '0' with "
1633 "ERROR_INVALID_PARAMETER)\n", res
, GetLastError(), needed
, status
);
1635 needed
= (DWORD
) 0xdeadbeef;
1636 status
= (DWORD
) 0xdeadbeef;
1637 SetLastError(0xdeadbeef);
1638 res
= pXcvDataW(hXcv
, cmd_MonitorUIW
, NULL
, 0, NULL
, len
, &needed
, &status
);
1639 ok( !res
&& (GetLastError() == RPC_X_NULL_REF_POINTER
),
1640 "returned %d with %u and %u for status %u (expected '0' with "
1641 "RPC_X_NULL_REF_POINTER)\n", res
, GetLastError(), needed
, status
);
1643 needed
= (DWORD
) 0xdeadbeef;
1644 status
= (DWORD
) 0xdeadbeef;
1645 SetLastError(0xdeadbeef);
1646 res
= pXcvDataW(hXcv
, cmd_MonitorUIW
, NULL
, 0, buffer
, len
, &needed
, NULL
);
1647 ok( !res
&& (GetLastError() == RPC_X_NULL_REF_POINTER
),
1648 "returned %d with %u and %u for status %u (expected '0' with "
1649 "RPC_X_NULL_REF_POINTER)\n", res
, GetLastError(), needed
, status
);
1651 /* off by one: larger */
1652 needed
= (DWORD
) 0xdeadbeef;
1653 status
= (DWORD
) 0xdeadbeef;
1654 SetLastError(0xdeadbeef);
1655 res
= pXcvDataW(hXcv
, cmd_MonitorUIW
, NULL
, 0, buffer
, len
+1, &needed
, &status
);
1656 ok( res
&& (status
== ERROR_SUCCESS
),
1657 "returned %d with %u and %u for status %u (expected '!= 0' for status "
1658 "ERROR_SUCCESS)\n", res
, GetLastError(), needed
, status
);
1660 /* off by one: smaller */
1661 /* the buffer is not modified for NT4, w2k, XP */
1662 needed
= (DWORD
) 0xdeadbeef;
1663 status
= (DWORD
) 0xdeadbeef;
1664 SetLastError(0xdeadbeef);
1665 res
= pXcvDataW(hXcv
, cmd_MonitorUIW
, NULL
, 0, buffer
, len
-1, &needed
, &status
);
1666 ok( res
&& (status
== ERROR_INSUFFICIENT_BUFFER
),
1667 "returned %d with %u and %u for status %u (expected '!= 0' for status "
1668 "ERROR_INSUFFICIENT_BUFFER)\n", res
, GetLastError(), needed
, status
);
1671 /* Normal use. The DLL-Name without a Path is returned */
1672 memset(buffer
, 0, len
);
1673 needed
= (DWORD
) 0xdeadbeef;
1674 status
= (DWORD
) 0xdeadbeef;
1675 SetLastError(0xdeadbeef);
1676 res
= pXcvDataW(hXcv
, cmd_MonitorUIW
, NULL
, 0, buffer
, len
, &needed
, &status
);
1677 ok( res
&& (status
== ERROR_SUCCESS
),
1678 "returned %d with %u and %u for status %u (expected '!= 0' for status "
1679 "ERROR_SUCCESS)\n", res
, GetLastError(), needed
, status
);
1684 /* ########################### */
1686 static void test_XcvDataW_PortIsValid(void)
1692 PRINTER_DEFAULTSA pd
;
1694 /* api is not present before w2k */
1695 if (pXcvDataW
== NULL
) return;
1697 pd
.pDatatype
= NULL
;
1699 pd
.DesiredAccess
= SERVER_ACCESS_ADMINISTER
;
1702 SetLastError(0xdeadbeef);
1703 res
= OpenPrinter(xcv_localport
, &hXcv
, &pd
);
1705 RETURN_ON_DEACTIVATED_SPOOLER(res
)
1706 ok(res
, "returned %d with %u and handle %p (expected '!= 0')\n", res
, GetLastError(), hXcv
);
1710 /* "PDWORD needed" is always required */
1711 needed
= (DWORD
) 0xdeadbeef;
1712 status
= (DWORD
) 0xdeadbeef;
1713 SetLastError(0xdeadbeef);
1714 res
= pXcvDataW(hXcv
, cmd_PortIsValidW
, (PBYTE
) portname_lpt1W
, sizeof(portname_lpt1W
), NULL
, 0, NULL
, &status
);
1715 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
1716 "returned %d with %u and %u for status %u (expected '!= 0' with ERROR_INVALID_PARAMETER)\n",
1717 res
, GetLastError(), needed
, status
);
1719 /* an empty name is not allowed */
1720 needed
= (DWORD
) 0xdeadbeef;
1721 status
= (DWORD
) 0xdeadbeef;
1722 SetLastError(0xdeadbeef);
1723 res
= pXcvDataW(hXcv
, cmd_PortIsValidW
, (PBYTE
) emptyW
, sizeof(emptyW
), NULL
, 0, &needed
, &status
);
1724 ok( res
&& ((status
== ERROR_FILE_NOT_FOUND
) || (status
== ERROR_PATH_NOT_FOUND
)),
1725 "returned %d with %u and %u for status %u (expected '!= 0' for status: "
1726 "ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND)\n",
1727 res
, GetLastError(), needed
, status
);
1729 /* a directory is not allowed */
1730 needed
= (DWORD
) 0xdeadbeef;
1731 status
= (DWORD
) 0xdeadbeef;
1732 SetLastError(0xdeadbeef);
1733 res
= pXcvDataW(hXcv
, cmd_PortIsValidW
, (PBYTE
) tempdirW
, (lstrlenW(tempdirW
) + 1) * sizeof(WCHAR
), NULL
, 0, &needed
, &status
);
1734 /* XP: ERROR_PATH_NOT_FOUND, w2k ERROR_ACCESS_DENIED */
1735 ok( res
&& ((status
== ERROR_PATH_NOT_FOUND
) || (status
== ERROR_ACCESS_DENIED
)),
1736 "returned %d with %u and %u for status %u (expected '!= 0' for status: "
1737 "ERROR_PATH_NOT_FOUND or ERROR_ACCESS_DENIED)\n",
1738 res
, GetLastError(), needed
, status
);
1740 /* more valid well known Ports */
1741 needed
= (DWORD
) 0xdeadbeef;
1742 status
= (DWORD
) 0xdeadbeef;
1743 SetLastError(0xdeadbeef);
1744 res
= pXcvDataW(hXcv
, cmd_PortIsValidW
, (PBYTE
) portname_lpt1W
, sizeof(portname_lpt1W
), NULL
, 0, &needed
, &status
);
1745 ok( res
&& (status
== ERROR_SUCCESS
),
1746 "returned %d with %u and %u for status %u (expected '!= 0' for ERROR_SUCCESS)\n",
1747 res
, GetLastError(), needed
, status
);
1749 needed
= (DWORD
) 0xdeadbeef;
1750 status
= (DWORD
) 0xdeadbeef;
1751 SetLastError(0xdeadbeef);
1752 res
= pXcvDataW(hXcv
, cmd_PortIsValidW
, (PBYTE
) portname_lpt2W
, sizeof(portname_lpt2W
), NULL
, 0, &needed
, &status
);
1753 ok( res
&& (status
== ERROR_SUCCESS
),
1754 "returned %d with %u and %u for status %u (expected '!= 0' for ERROR_SUCCESS)\n",
1755 res
, GetLastError(), needed
, status
);
1757 needed
= (DWORD
) 0xdeadbeef;
1758 status
= (DWORD
) 0xdeadbeef;
1759 SetLastError(0xdeadbeef);
1760 res
= pXcvDataW(hXcv
, cmd_PortIsValidW
, (PBYTE
) portname_com1W
, sizeof(portname_com1W
), NULL
, 0, &needed
, &status
);
1761 ok( res
&& (status
== ERROR_SUCCESS
),
1762 "returned %d with %u and %u for status %u (expected '!= 0' for ERROR_SUCCESS)\n",
1763 res
, GetLastError(), needed
, status
);
1765 needed
= (DWORD
) 0xdeadbeef;
1766 status
= (DWORD
) 0xdeadbeef;
1767 SetLastError(0xdeadbeef);
1768 res
= pXcvDataW(hXcv
, cmd_PortIsValidW
, (PBYTE
) portname_com2W
, sizeof(portname_com2W
), NULL
, 0, &needed
, &status
);
1769 ok( res
&& (status
== ERROR_SUCCESS
),
1770 "returned %d with %u and %u for status %u (expected '!= 0' for ERROR_SUCCESS)\n",
1771 res
, GetLastError(), needed
, status
);
1773 needed
= (DWORD
) 0xdeadbeef;
1774 status
= (DWORD
) 0xdeadbeef;
1775 SetLastError(0xdeadbeef);
1776 res
= pXcvDataW(hXcv
, cmd_PortIsValidW
, (PBYTE
) portname_fileW
, sizeof(portname_fileW
), NULL
, 0, &needed
, &status
);
1777 ok( res
&& (status
== ERROR_SUCCESS
),
1778 "returned %d with %u and %u for status %u (expected '!= 0' with ERROR_SUCCESS)\n",
1779 res
, GetLastError(), needed
, status
);
1782 /* a normal, writable file is allowed */
1783 needed
= (DWORD
) 0xdeadbeef;
1784 status
= (DWORD
) 0xdeadbeef;
1785 SetLastError(0xdeadbeef);
1786 res
= pXcvDataW(hXcv
, cmd_PortIsValidW
, (PBYTE
) tempfileW
, (lstrlenW(tempfileW
) + 1) * sizeof(WCHAR
), NULL
, 0, &needed
, &status
);
1787 ok( res
&& (status
== ERROR_SUCCESS
),
1788 "returned %d with %u and %u for status %u (expected '!= 0' with ERROR_SUCCESS)\n",
1789 res
, GetLastError(), needed
, status
);
1794 /* ########################### */
1796 static void test_GetPrinterDriver(void)
1802 DWORD needed
, filled
;
1804 if (!default_printer
)
1806 skip("There is no default printer installed\n");
1811 ret
= OpenPrinter(default_printer
, &hprn
, NULL
);
1814 skip("Unable to open the default printer (%s)\n", default_printer
);
1817 ok(hprn
!= 0, "wrong hprn %p\n", hprn
);
1819 for (level
= -1; level
<= 7; level
++)
1821 SetLastError(0xdeadbeef);
1823 ret
= GetPrinterDriver(hprn
, NULL
, level
, NULL
, 0, &needed
);
1824 ok(!ret
, "level %d: GetPrinterDriver should fail\n", level
);
1825 if (level
>= 1 && level
<= 6)
1827 /* Not all levels are supported on all Windows-Versions */
1828 if(GetLastError() == ERROR_INVALID_LEVEL
) continue;
1829 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "wrong error %d\n", GetLastError());
1830 ok(needed
> 0,"not expected needed buffer size %d\n", needed
);
1834 /* ERROR_OUTOFMEMORY found on win9x */
1835 ok( ((GetLastError() == ERROR_INVALID_LEVEL
) ||
1836 (GetLastError() == ERROR_OUTOFMEMORY
)),
1837 "%d: returned %d with %d (expected '0' with: "
1838 "ERROR_INVALID_LEVEL or ERROR_OUTOFMEMORY)\n",
1839 level
, ret
, GetLastError());
1840 /* needed is modified in win9x. The modified Value depends on the
1841 default Printer. testing for "needed == (DWORD)-1" will fail */
1845 buf
= HeapAlloc(GetProcessHeap(), 0, needed
);
1847 SetLastError(0xdeadbeef);
1849 ret
= GetPrinterDriver(hprn
, NULL
, level
, buf
, needed
, &filled
);
1850 ok(ret
, "level %d: GetPrinterDriver error %d\n", level
, GetLastError());
1851 ok(needed
== filled
, "needed %d != filled %d\n", needed
, filled
);
1855 DRIVER_INFO_2
*di_2
= (DRIVER_INFO_2
*)buf
;
1856 DWORD calculated
= sizeof(*di_2
);
1858 /* MSDN is wrong: The Drivers on the win9x-CD's have cVersion=0x0400
1859 NT351: 1, NT4.0+w2k(Kernelmode): 2, w2k and above(Usermode): 3 */
1860 ok((di_2
->cVersion
>= 0 && di_2
->cVersion
<= 3) ||
1861 (di_2
->cVersion
== 0x0400), "di_2->cVersion = %d\n", di_2
->cVersion
);
1862 ok(di_2
->pName
!= NULL
, "not expected NULL ptr\n");
1863 ok(di_2
->pEnvironment
!= NULL
, "not expected NULL ptr\n");
1864 ok(di_2
->pDriverPath
!= NULL
, "not expected NULL ptr\n");
1865 ok(di_2
->pDataFile
!= NULL
, "not expected NULL ptr\n");
1866 ok(di_2
->pConfigFile
!= NULL
, "not expected NULL ptr\n");
1868 trace("cVersion %d\n", di_2
->cVersion
);
1869 trace("pName %s\n", di_2
->pName
);
1870 calculated
+= strlen(di_2
->pName
) + 1;
1871 trace("pEnvironment %s\n", di_2
->pEnvironment
);
1872 calculated
+= strlen(di_2
->pEnvironment
) + 1;
1873 trace("pDriverPath %s\n", di_2
->pDriverPath
);
1874 calculated
+= strlen(di_2
->pDriverPath
) + 1;
1875 trace("pDataFile %s\n", di_2
->pDataFile
);
1876 calculated
+= strlen(di_2
->pDataFile
) + 1;
1877 trace("pConfigFile %s\n", di_2
->pConfigFile
);
1878 calculated
+= strlen(di_2
->pConfigFile
) + 1;
1880 /* XP allocates memory for both ANSI and unicode names */
1881 ok(filled
>= calculated
,"calculated %d != filled %d\n", calculated
, filled
);
1884 HeapFree(GetProcessHeap(), 0, buf
);
1887 SetLastError(0xdeadbeef);
1888 ret
= ClosePrinter(hprn
);
1889 ok(ret
, "ClosePrinter error %d\n", GetLastError());
1892 static void test_DEVMODE(const DEVMODE
*dm
, LONG dmSize
, LPCSTR exp_prn_name
)
1894 /* On NT3.51, some fields in DEVMODE are empty/zero
1895 (dmDeviceName, dmSpecVersion, dmDriverVersion and dmDriverExtra)
1896 We skip the Tests on this Platform */
1897 if (dm
->dmSpecVersion
|| dm
->dmDriverVersion
|| dm
->dmDriverExtra
) {
1898 /* The 0-terminated Printername can be larger (MAX_PATH) than CCHDEVICENAME */
1899 ok(!strncmp(exp_prn_name
, (LPCSTR
)dm
->dmDeviceName
, CCHDEVICENAME
-1),
1900 "expected '%s', got '%s'\n", exp_prn_name
, dm
->dmDeviceName
);
1901 ok(dm
->dmSize
+ dm
->dmDriverExtra
== dmSize
,
1902 "%u != %d\n", dm
->dmSize
+ dm
->dmDriverExtra
, dmSize
);
1904 trace("dmFields %08x\n", dm
->dmFields
);
1907 static void test_DocumentProperties(void)
1913 if (!default_printer
)
1915 skip("There is no default printer installed\n");
1920 ret
= OpenPrinter(default_printer
, &hprn
, NULL
);
1923 skip("Unable to open the default printer (%s)\n", default_printer
);
1926 ok(hprn
!= 0, "wrong hprn %p\n", hprn
);
1928 dm_size
= DocumentProperties(0, hprn
, NULL
, NULL
, NULL
, 0);
1929 trace("DEVMODE required size %d\n", dm_size
);
1930 ok(dm_size
>= sizeof(DEVMODE
), "unexpected DocumentProperties ret value %d\n", dm_size
);
1932 dm
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dm_size
);
1934 ret
= DocumentProperties(0, hprn
, NULL
, dm
, dm
, DM_OUT_BUFFER
);
1935 ok(ret
== IDOK
, "DocumentProperties ret value %d != expected IDOK\n", ret
);
1937 test_DEVMODE(dm
, dm_size
, default_printer
);
1939 HeapFree(GetProcessHeap(), 0, dm
);
1941 SetLastError(0xdeadbeef);
1942 ret
= ClosePrinter(hprn
);
1943 ok(ret
, "ClosePrinter error %d\n", GetLastError());
1946 static void test_EnumPrinters(void)
1948 DWORD neededA
, neededW
, num
;
1951 SetLastError(0xdeadbeef);
1953 ret
= EnumPrintersA(PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &neededA
, &num
);
1954 RETURN_ON_DEACTIVATED_SPOOLER(ret
)
1957 /* We have 1 or more printers */
1958 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "gle %d\n", GetLastError());
1959 ok(neededA
> 0, "Expected neededA to show the number of needed bytes\n");
1963 /* We don't have any printers defined */
1964 ok(GetLastError() == S_OK
, "gle %d\n", GetLastError());
1965 ok(neededA
== 0, "Expected neededA to be zero\n");
1967 ok(num
== 0, "num %d\n", num
);
1969 SetLastError(0xdeadbeef);
1971 ret
= EnumPrintersW(PRINTER_ENUM_LOCAL
, NULL
, 2, NULL
, 0, &neededW
, &num
);
1972 /* EnumPrintersW is not supported on all platforms */
1973 if (!ret
&& (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
))
1975 skip("EnumPrintersW is not implemented\n");
1981 /* We have 1 or more printers */
1982 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "gle %d\n", GetLastError());
1983 ok(neededW
> 0, "Expected neededW to show the number of needed bytes\n");
1987 /* We don't have any printers defined */
1988 ok(GetLastError() == S_OK
, "gle %d\n", GetLastError());
1989 ok(neededW
== 0, "Expected neededW to be zero\n");
1991 ok(num
== 0, "num %d\n", num
);
1993 /* Outlook2003 relies on the buffer size returned by EnumPrintersA being big enough
1994 to hold the buffer returned by EnumPrintersW */
1995 ok(neededA
== neededW
, "neededA %d neededW %d\n", neededA
, neededW
);
1998 static void test_DeviceCapabilities(void)
2001 BOOL (WINAPI
*pPrintDlgA
)(PRINTDLGA
*);
2005 const char *driver
, *device
, *port
;
2013 INT n_papers
, n_paper_size
, n_paper_names
, n_copies
, ret
;
2016 hComdlg32
= LoadLibrary("comdlg32.dll");
2018 pPrintDlgA
= (void *)GetProcAddress(hComdlg32
, "PrintDlgA");
2021 memset(&prn_dlg
, 0, sizeof(prn_dlg
));
2022 prn_dlg
.lStructSize
= sizeof(prn_dlg
);
2023 prn_dlg
.Flags
= PD_RETURNDEFAULT
;
2024 ret
= pPrintDlgA(&prn_dlg
);
2025 FreeLibrary(hComdlg32
);
2028 skip("PrintDlg returned no default printer\n");
2031 ok(prn_dlg
.hDevMode
!= 0, "PrintDlg returned hDevMode == NULL\n");
2032 ok(prn_dlg
.hDevNames
!= 0, "PrintDlg returned hDevNames == NULL\n");
2034 dm
= GlobalLock(prn_dlg
.hDevMode
);
2035 ok(dm
!= NULL
, "GlobalLock(prn_dlg.hDevMode) failed\n");
2036 trace("dmDeviceName \"%s\"\n", dm
->dmDeviceName
);
2038 dn
= GlobalLock(prn_dlg
.hDevNames
);
2039 ok(dn
!= NULL
, "GlobalLock(prn_dlg.hDevNames) failed\n");
2040 ok(dn
->wDriverOffset
, "expected not 0 wDriverOffset\n");
2041 ok(dn
->wDeviceOffset
, "expected not 0 wDeviceOffset\n");
2042 ok(dn
->wOutputOffset
, "expected not 0 wOutputOffset\n");
2043 ok(dn
->wDefault
== DN_DEFAULTPRN
, "expected DN_DEFAULTPRN got %x\n", dn
->wDefault
);
2044 driver
= (const char *)dn
+ dn
->wDriverOffset
;
2045 device
= (const char *)dn
+ dn
->wDeviceOffset
;
2046 port
= (const char *)dn
+ dn
->wOutputOffset
;
2047 trace("driver \"%s\" device \"%s\" port \"%s\"\n", driver
, device
, port
);
2049 test_DEVMODE(dm
, dm
->dmSize
+ dm
->dmDriverExtra
, device
);
2051 n_papers
= DeviceCapabilities(device
, port
, DC_PAPERS
, NULL
, NULL
);
2052 ok(n_papers
> 0, "DeviceCapabilities DC_PAPERS failed\n");
2053 papers
= HeapAlloc(GetProcessHeap(), 0, sizeof(*papers
) * n_papers
);
2054 ret
= DeviceCapabilities(device
, port
, DC_PAPERS
, (LPSTR
)papers
, NULL
);
2055 ok(ret
== n_papers
, "expected %d, got %d\n", n_papers
, ret
);
2057 for (ret
= 0; ret
< n_papers
; ret
++)
2058 trace("papers[%d] = %d\n", ret
, papers
[ret
]);
2060 HeapFree(GetProcessHeap(), 0, papers
);
2062 n_paper_size
= DeviceCapabilities(device
, port
, DC_PAPERSIZE
, NULL
, NULL
);
2063 ok(n_paper_size
> 0, "DeviceCapabilities DC_PAPERSIZE failed\n");
2064 ok(n_paper_size
== n_papers
, "n_paper_size %d != n_papers %d\n", n_paper_size
, n_papers
);
2065 paper_size
= HeapAlloc(GetProcessHeap(), 0, sizeof(*paper_size
) * n_paper_size
);
2066 ret
= DeviceCapabilities(device
, port
, DC_PAPERSIZE
, (LPSTR
)paper_size
, NULL
);
2067 ok(ret
== n_paper_size
, "expected %d, got %d\n", n_paper_size
, ret
);
2069 for (ret
= 0; ret
< n_paper_size
; ret
++)
2070 trace("paper_size[%d] = %d x %d\n", ret
, paper_size
[ret
].x
, paper_size
[ret
].y
);
2072 HeapFree(GetProcessHeap(), 0, paper_size
);
2074 n_paper_names
= DeviceCapabilities(device
, port
, DC_PAPERNAMES
, NULL
, NULL
);
2075 ok(n_paper_names
> 0, "DeviceCapabilities DC_PAPERNAMES failed\n");
2076 ok(n_paper_names
== n_papers
, "n_paper_names %d != n_papers %d\n", n_paper_names
, n_papers
);
2077 paper_name
= HeapAlloc(GetProcessHeap(), 0, sizeof(*paper_name
) * n_paper_names
);
2078 ret
= DeviceCapabilities(device
, port
, DC_PAPERNAMES
, (LPSTR
)paper_name
, NULL
);
2079 ok(ret
== n_paper_names
, "expected %d, got %d\n", n_paper_names
, ret
);
2081 for (ret
= 0; ret
< n_paper_names
; ret
++)
2082 trace("paper_name[%u] = %s\n", ret
, paper_name
[ret
].name
);
2084 HeapFree(GetProcessHeap(), 0, paper_name
);
2086 n_copies
= DeviceCapabilities(device
, port
, DC_COPIES
, NULL
, dm
);
2087 ok(n_copies
> 0, "DeviceCapabilities DC_COPIES failed\n");
2088 trace("n_copies = %d\n", n_copies
);
2090 ret
= DeviceCapabilities(device
, port
, DC_MAXEXTENT
, NULL
, NULL
);
2091 ok(ret
!= -1, "DeviceCapabilities DC_MAXEXTENT failed\n");
2092 ext
= MAKEPOINTS(ret
);
2093 trace("max ext = %d x %d\n", ext
.x
, ext
.y
);
2095 ret
= DeviceCapabilities(device
, port
, DC_MINEXTENT
, NULL
, NULL
);
2096 ok(ret
!= -1, "DeviceCapabilities DC_MINEXTENT failed\n");
2097 ext
= MAKEPOINTS(ret
);
2098 trace("min ext = %d x %d\n", ext
.x
, ext
.y
);
2100 fields
= DeviceCapabilities(device
, port
, DC_FIELDS
, NULL
, NULL
);
2101 ok(fields
!= (DWORD
)-1, "DeviceCapabilities DC_FIELDS failed\n");
2102 ok(fields
== dm
->dmFields
, "fields %x != dm->dmFields %x\n", fields
, dm
->dmFields
);
2104 GlobalUnlock(prn_dlg
.hDevMode
);
2105 GlobalFree(prn_dlg
.hDevMode
);
2106 GlobalUnlock(prn_dlg
.hDevNames
);
2107 GlobalFree(prn_dlg
.hDevNames
);
2112 hwinspool
= GetModuleHandleA("winspool.drv");
2113 pGetDefaultPrinterA
= (void *) GetProcAddress(hwinspool
, "GetDefaultPrinterA");
2114 pSetDefaultPrinterA
= (void *) GetProcAddress(hwinspool
, "SetDefaultPrinterA");
2115 pXcvDataW
= (void *) GetProcAddress(hwinspool
, "XcvDataW");
2117 find_default_printer();
2118 find_local_server();
2123 test_ConfigurePort();
2124 test_DeleteMonitor();
2126 test_DeviceCapabilities();
2127 test_DocumentProperties();
2128 test_EnumForms(NULL
);
2129 if (default_printer
) test_EnumForms(default_printer
);
2130 test_EnumMonitors();
2132 test_EnumPrinters();
2133 test_GetDefaultPrinter();
2134 test_GetPrinterDriverDirectory();
2135 test_GetPrintProcessorDirectory();
2137 test_GetPrinterDriver();
2138 test_SetDefaultPrinter();
2139 test_XcvDataW_MonitorUI();
2140 test_XcvDataW_PortIsValid();
2142 /* Cleanup our temporary file */
2143 DeleteFileA(tempfileA
);