2003-01-15 01:50:48 +01:00
|
|
|
/*
|
2004-03-07 04:46:54 +01:00
|
|
|
* Copyright (C) 2003, 2004 Stefan Leichter
|
2006-04-10 00:29:22 +02:00
|
|
|
* Copyright (C) 2005, 2006 Detlef Riekenberg
|
2006-04-14 15:34:57 +02:00
|
|
|
* Copyright (C) 2006 Dmitry Timoshkov
|
2003-01-15 01:50:48 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-01-15 01:50:48 +01:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2007-04-07 10:28:10 +02:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
#define NONAMELESSUNION
|
2003-09-06 01:08:26 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
2003-01-15 01:50:48 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wingdi.h"
|
2007-04-07 10:28:10 +02:00
|
|
|
#include "winnls.h"
|
2006-04-18 12:36:58 +02:00
|
|
|
#include "winuser.h"
|
2005-12-12 13:02:15 +01:00
|
|
|
#include "winreg.h"
|
2003-01-15 01:50:48 +01:00
|
|
|
#include "winspool.h"
|
2007-04-07 10:28:10 +02:00
|
|
|
#include "commdlg.h"
|
|
|
|
#include "wine/test.h"
|
2003-01-15 01:50:48 +01:00
|
|
|
|
2006-05-27 12:09:52 +02:00
|
|
|
#define MAGIC_DEAD 0xdeadbeef
|
2005-12-12 13:02:15 +01:00
|
|
|
#define DEFAULT_PRINTER_SIZE 1000
|
2005-11-15 17:51:45 +01:00
|
|
|
|
2010-06-15 17:25:17 +02:00
|
|
|
static CHAR defaultspooldirectory[] = "DefaultSpoolDirectory";
|
2006-12-22 00:48:08 +01:00
|
|
|
static CHAR does_not_exist_dll[]= "does_not_exist.dll";
|
|
|
|
static CHAR does_not_exist[] = "does_not_exist";
|
2006-09-10 19:01:30 +02:00
|
|
|
static CHAR empty[] = "";
|
2009-02-04 23:16:28 +01:00
|
|
|
static CHAR env_x64[] = "Windows x64";
|
2006-09-10 19:01:30 +02:00
|
|
|
static CHAR env_x86[] = "Windows NT x86";
|
|
|
|
static CHAR env_win9x_case[] = "windowS 4.0";
|
|
|
|
static CHAR illegal_name[] = "illegal,name";
|
|
|
|
static CHAR invalid_env[] = "invalid_env";
|
2007-06-18 00:58:49 +02:00
|
|
|
static CHAR LocalPortA[] = "Local Port";
|
2006-11-07 00:07:48 +01:00
|
|
|
static CHAR portname_com1[] = "COM1:";
|
|
|
|
static CHAR portname_file[] = "FILE:";
|
|
|
|
static CHAR portname_lpt1[] = "LPT1:";
|
2009-10-16 14:56:34 +02:00
|
|
|
static CHAR server_does_not_exist[] = "\\\\does_not_exist";
|
2006-09-10 19:01:30 +02:00
|
|
|
static CHAR version_dll[] = "version.dll";
|
2007-02-02 00:46:03 +01:00
|
|
|
static CHAR winetest[] = "winetest";
|
|
|
|
static CHAR xcv_localport[] = ",XcvMonitor Local Port";
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
static HANDLE hwinspool;
|
2007-06-18 00:58:49 +02:00
|
|
|
static BOOL (WINAPI * pAddPortExA)(LPSTR, DWORD, LPBYTE, LPSTR);
|
2010-06-15 17:25:17 +02:00
|
|
|
static BOOL (WINAPI * pEnumPrinterDriversW)(LPWSTR, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
|
|
|
|
static BOOL (WINAPI * pGetDefaultPrinterA)(LPSTR, LPDWORD);
|
|
|
|
static DWORD (WINAPI * pGetPrinterDataExA)(HANDLE, LPCSTR, LPCSTR, LPDWORD, LPBYTE, DWORD, LPDWORD);
|
2009-11-24 14:31:21 +01:00
|
|
|
static BOOL (WINAPI * pGetPrinterDriverW)(HANDLE, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD);
|
2009-12-01 00:04:19 +01:00
|
|
|
static BOOL (WINAPI * pGetPrinterW)(HANDLE, DWORD, LPBYTE, DWORD, LPDWORD);
|
2010-06-15 17:25:17 +02:00
|
|
|
static BOOL (WINAPI * pSetDefaultPrinterA)(LPCSTR);
|
|
|
|
static DWORD (WINAPI * pXcvDataW)(HANDLE, LPCWSTR, PBYTE, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
|
2007-02-02 00:46:03 +01:00
|
|
|
|
|
|
|
/* ################################ */
|
2005-12-12 13:02:15 +01:00
|
|
|
|
2006-04-10 00:29:22 +02:00
|
|
|
struct monitor_entry {
|
|
|
|
LPSTR env;
|
2006-07-25 22:53:32 +02:00
|
|
|
CHAR dllname[32];
|
2006-04-10 00:29:22 +02:00
|
|
|
};
|
|
|
|
|
2007-02-02 16:04:46 +01:00
|
|
|
static LPSTR default_printer = NULL;
|
|
|
|
static LPSTR local_server = NULL;
|
|
|
|
static LPSTR tempdirA = NULL;
|
|
|
|
static LPSTR tempfileA = NULL;
|
|
|
|
static LPWSTR tempdirW = NULL;
|
|
|
|
static LPWSTR tempfileW = NULL;
|
2006-12-12 10:22:32 +01:00
|
|
|
|
2013-02-11 09:47:35 +01:00
|
|
|
static BOOL is_spooler_deactivated(DWORD res, DWORD lasterror)
|
|
|
|
{
|
|
|
|
if (!res && lasterror == RPC_S_SERVER_UNAVAILABLE)
|
|
|
|
{
|
|
|
|
static int deactivated_spooler_reported = 0;
|
|
|
|
if (!deactivated_spooler_reported)
|
|
|
|
{
|
|
|
|
deactivated_spooler_reported = 1;
|
|
|
|
skip("The service 'Spooler' is required for many tests\n");
|
|
|
|
}
|
|
|
|
return TRUE;
|
2006-02-02 13:50:36 +01:00
|
|
|
}
|
2013-02-11 09:47:35 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-02-02 13:50:36 +01:00
|
|
|
|
2013-02-11 09:47:35 +01:00
|
|
|
static BOOL is_access_denied(DWORD res, DWORD lasterror)
|
|
|
|
{
|
|
|
|
if (!res && lasterror == ERROR_ACCESS_DENIED)
|
|
|
|
{
|
|
|
|
static int access_denied_reported = 0;
|
|
|
|
if (!access_denied_reported)
|
|
|
|
{
|
|
|
|
access_denied_reported = 1;
|
|
|
|
skip("More access rights are required for many tests\n");
|
|
|
|
}
|
|
|
|
return TRUE;
|
2007-08-13 12:07:57 +02:00
|
|
|
}
|
2013-02-11 09:47:35 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2005-12-12 13:02:15 +01:00
|
|
|
|
2006-12-12 17:18:57 +01:00
|
|
|
static void find_default_printer(VOID)
|
2005-12-12 13:02:15 +01:00
|
|
|
{
|
|
|
|
static char buffer[DEFAULT_PRINTER_SIZE];
|
|
|
|
DWORD needed;
|
|
|
|
DWORD res;
|
|
|
|
LPSTR ptr;
|
|
|
|
|
|
|
|
if ((default_printer == NULL) && (pGetDefaultPrinterA))
|
|
|
|
{
|
|
|
|
/* w2k and above */
|
|
|
|
needed = sizeof(buffer);
|
|
|
|
res = pGetDefaultPrinterA(buffer, &needed);
|
|
|
|
if(res) default_printer = buffer;
|
2011-08-29 21:11:23 +02:00
|
|
|
trace("default_printer: '%s'\n", default_printer ? default_printer : "(null)");
|
2005-12-12 13:02:15 +01:00
|
|
|
}
|
|
|
|
if (default_printer == NULL)
|
|
|
|
{
|
|
|
|
HKEY hwindows;
|
|
|
|
DWORD type;
|
|
|
|
/* NT 3.x and above */
|
2013-10-24 23:06:43 +02:00
|
|
|
if (RegOpenKeyExA(HKEY_CURRENT_USER,
|
|
|
|
"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows",
|
|
|
|
0, KEY_QUERY_VALUE, &hwindows) == NO_ERROR) {
|
2005-12-12 13:02:15 +01:00
|
|
|
|
|
|
|
needed = sizeof(buffer);
|
2013-10-24 23:06:43 +02:00
|
|
|
if (RegQueryValueExA(hwindows, "device", NULL, &type, (LPBYTE)buffer, &needed) == NO_ERROR) {
|
2005-12-12 13:02:15 +01:00
|
|
|
ptr = strchr(buffer, ',');
|
|
|
|
if (ptr) {
|
|
|
|
ptr[0] = '\0';
|
|
|
|
default_printer = buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(hwindows);
|
|
|
|
}
|
2011-08-29 21:11:23 +02:00
|
|
|
trace("default_printer: '%s'\n", default_printer ? default_printer : "(null)");
|
2005-12-12 13:02:15 +01:00
|
|
|
}
|
|
|
|
if (default_printer == NULL)
|
|
|
|
{
|
|
|
|
/* win9x */
|
|
|
|
needed = sizeof(buffer);
|
|
|
|
res = GetProfileStringA("windows", "device", "*", buffer, needed);
|
|
|
|
if(res) {
|
|
|
|
ptr = strchr(buffer, ',');
|
|
|
|
if (ptr) {
|
|
|
|
ptr[0] = '\0';
|
|
|
|
default_printer = buffer;
|
|
|
|
}
|
|
|
|
}
|
2011-08-29 21:11:23 +02:00
|
|
|
trace("default_printer: '%s'\n", default_printer ? default_printer : "(null)");
|
2005-12-12 13:02:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
static struct monitor_entry * find_installed_monitor(void)
|
|
|
|
{
|
|
|
|
MONITOR_INFO_2A mi2a;
|
|
|
|
static struct monitor_entry * entry = NULL;
|
|
|
|
DWORD num_tests;
|
|
|
|
DWORD i = 0;
|
|
|
|
|
|
|
|
static struct monitor_entry monitor_table[] = {
|
|
|
|
{env_win9x_case, "localspl.dll"},
|
|
|
|
{env_x86, "localspl.dll"},
|
2009-02-04 23:16:28 +01:00
|
|
|
{env_x64, "localspl.dll"},
|
2006-04-10 00:29:22 +02:00
|
|
|
{env_win9x_case, "localmon.dll"},
|
|
|
|
{env_x86, "localmon.dll"},
|
|
|
|
{env_win9x_case, "tcpmon.dll"},
|
|
|
|
{env_x86, "tcpmon.dll"},
|
|
|
|
{env_win9x_case, "usbmon.dll"},
|
|
|
|
{env_x86, "usbmon.dll"},
|
|
|
|
{env_win9x_case, "mspp32.dll"},
|
|
|
|
{env_x86, "win32spl.dll"},
|
|
|
|
{env_x86, "redmonnt.dll"},
|
|
|
|
{env_x86, "redmon35.dll"},
|
|
|
|
{env_win9x_case, "redmon95.dll"},
|
|
|
|
{env_x86, "pdfcmnnt.dll"},
|
|
|
|
{env_win9x_case, "pdfcmn95.dll"},
|
|
|
|
};
|
|
|
|
|
|
|
|
if (entry) return entry;
|
|
|
|
|
2018-05-29 01:05:28 +02:00
|
|
|
num_tests = ARRAY_SIZE(monitor_table);
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
/* cleanup */
|
2009-02-04 23:16:28 +01:00
|
|
|
DeleteMonitorA(NULL, env_x64, winetest);
|
2007-01-15 05:37:14 +01:00
|
|
|
DeleteMonitorA(NULL, env_x86, winetest);
|
|
|
|
DeleteMonitorA(NULL, env_win9x_case, winetest);
|
2006-04-10 00:29:22 +02:00
|
|
|
|
2007-01-15 05:37:14 +01:00
|
|
|
/* find a usable monitor from the table */
|
|
|
|
mi2a.pName = winetest;
|
2006-04-10 00:29:22 +02:00
|
|
|
while ((entry == NULL) && (i < num_tests)) {
|
|
|
|
entry = &monitor_table[i];
|
|
|
|
i++;
|
|
|
|
mi2a.pEnvironment = entry->env;
|
|
|
|
mi2a.pDLLName = entry->dllname;
|
|
|
|
|
|
|
|
if (AddMonitorA(NULL, 2, (LPBYTE) &mi2a)) {
|
|
|
|
/* we got one */
|
|
|
|
trace("using '%s', '%s'\n", entry->env, entry->dllname);
|
2007-01-15 05:37:14 +01:00
|
|
|
DeleteMonitorA(NULL, entry->env, winetest);
|
2006-04-10 00:29:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
entry = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
2006-12-22 00:48:16 +01:00
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
|
|
|
static void find_local_server(VOID)
|
|
|
|
{
|
|
|
|
static char buffer[MAX_PATH];
|
|
|
|
DWORD res;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
size = sizeof(buffer) - 3 ;
|
|
|
|
buffer[0] = '\\';
|
|
|
|
buffer[1] = '\\';
|
|
|
|
buffer[2] = '\0';
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetComputerNameA(&buffer[2], &size);
|
|
|
|
trace("returned %d with %d and %d: '%s'\n", res, GetLastError(), size, buffer);
|
|
|
|
|
|
|
|
ok( res != 0, "returned %d with %d and %d: '%s' (expected '!= 0')\n",
|
|
|
|
res, GetLastError(), size, buffer);
|
|
|
|
|
|
|
|
if (res) local_server = buffer;
|
|
|
|
}
|
|
|
|
|
2006-04-10 00:29:22 +02:00
|
|
|
/* ########################### */
|
|
|
|
|
2007-02-02 16:04:46 +01:00
|
|
|
static void find_tempfile(VOID)
|
|
|
|
{
|
|
|
|
static CHAR buffer_dirA[MAX_PATH];
|
|
|
|
static CHAR buffer_fileA[MAX_PATH];
|
|
|
|
static WCHAR buffer_dirW[MAX_PATH];
|
|
|
|
static WCHAR buffer_fileW[MAX_PATH];
|
|
|
|
DWORD res;
|
|
|
|
int resint;
|
|
|
|
|
|
|
|
memset(buffer_dirA, 0, MAX_PATH - 1);
|
|
|
|
buffer_dirA[MAX_PATH - 1] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetTempPathA(MAX_PATH, buffer_dirA);
|
|
|
|
ok(res, "returned %u with %u and '%s' (expected '!= 0')\n", res, GetLastError(), buffer_dirA);
|
|
|
|
if (res == 0) return;
|
|
|
|
|
|
|
|
memset(buffer_fileA, 0, MAX_PATH - 1);
|
|
|
|
buffer_fileA[MAX_PATH - 1] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetTempFileNameA(buffer_dirA, winetest, 0, buffer_fileA);
|
|
|
|
ok(res, "returned %u with %u and '%s' (expected '!= 0')\n", res, GetLastError(), buffer_fileA);
|
|
|
|
if (res == 0) return;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
resint = MultiByteToWideChar(CP_ACP, 0, buffer_dirA, -1, buffer_dirW, MAX_PATH);
|
|
|
|
ok(res, "returned %u with %u (expected '!= 0')\n", resint, GetLastError());
|
|
|
|
if (resint == 0) return;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
resint = MultiByteToWideChar(CP_ACP, 0, buffer_fileA, -1, buffer_fileW, MAX_PATH);
|
|
|
|
ok(res, "returned %u with %u (expected '!= 0')\n", resint, GetLastError());
|
|
|
|
if (resint == 0) return;
|
|
|
|
|
|
|
|
tempdirA = buffer_dirA;
|
|
|
|
tempfileA = buffer_fileA;
|
|
|
|
tempdirW = buffer_dirW;
|
|
|
|
tempfileW = buffer_fileW;
|
|
|
|
trace("tempfile: '%s'\n", tempfileA);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
static void test_AddMonitor(void)
|
|
|
|
{
|
|
|
|
MONITOR_INFO_2A mi2a;
|
|
|
|
struct monitor_entry * entry = NULL;
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
entry = find_installed_monitor();
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 1, NULL);
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_LEVEL),
|
2006-10-13 13:20:32 +02:00
|
|
|
"returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
|
2006-04-10 00:29:22 +02:00
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 3, NULL);
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_LEVEL),
|
2006-10-13 13:20:32 +02:00
|
|
|
"returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
|
2006-04-10 00:29:22 +02:00
|
|
|
res, GetLastError());
|
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* This test crashes win9x on vmware (works with win9x on qemu 0.8.1) */
|
2006-04-10 00:29:22 +02:00
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 2, NULL);
|
|
|
|
/* NT: unchanged, 9x: ERROR_PRIVILEGE_NOT_HELD */
|
|
|
|
ok(!res &&
|
|
|
|
((GetLastError() == MAGIC_DEAD) ||
|
|
|
|
(GetLastError() == ERROR_PRIVILEGE_NOT_HELD)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: MAGIC_DEAD or "
|
2006-04-10 00:29:22 +02:00
|
|
|
"ERROR_PRIVILEGE_NOT_HELD)\n", res, GetLastError());
|
|
|
|
|
|
|
|
ZeroMemory(&mi2a, sizeof(MONITOR_INFO_2A));
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
|
|
|
if (is_access_denied(res, GetLastError())) return;
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
/* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_INVALID_ENVIRONMENT */
|
|
|
|
ok(!res && ((GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_ENVIRONMENT)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
|
2006-04-10 00:29:22 +02:00
|
|
|
"ERROR_INVALID_ENVIRONMENT)\n", res, GetLastError());
|
|
|
|
|
|
|
|
if (!entry) {
|
2007-03-05 21:44:18 +01:00
|
|
|
skip("No usable Monitor found\n");
|
2006-04-10 00:29:22 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-06 19:24:22 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2012-06-24 19:40:56 +02:00
|
|
|
/* The test is deactivated, because when mi2a.pName is NULL, the subkey
|
2006-04-10 00:29:22 +02:00
|
|
|
HKLM\System\CurrentControlSet\Control\Print\Monitors\C:\WINDOWS\SYSTEM
|
2008-10-18 19:23:08 +02:00
|
|
|
or HKLM\System\CurrentControlSet\Control\Print\Monitors\ì
|
2006-04-10 00:29:22 +02:00
|
|
|
is created on win9x and we do not want to hit this bug here. */
|
|
|
|
|
|
|
|
mi2a.pEnvironment = entry->env;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
2011-02-05 08:08:04 +01:00
|
|
|
ok(res, "AddMonitor error %d\n", GetLastError());
|
2006-04-10 00:29:22 +02:00
|
|
|
/* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
|
2007-01-06 19:24:22 +01:00
|
|
|
}
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
mi2a.pEnvironment = entry->env;
|
2006-07-12 23:31:46 +02:00
|
|
|
mi2a.pName = empty;
|
2006-04-10 00:29:22 +02:00
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
/* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
|
|
|
|
ok( !res &&
|
|
|
|
((GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
(GetLastError() == ERROR_PRIVILEGE_NOT_HELD)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
|
2006-04-10 00:29:22 +02:00
|
|
|
"ERROR_PRIVILEGE_NOT_HELD)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
2007-01-15 05:37:14 +01:00
|
|
|
mi2a.pName = winetest;
|
2006-04-10 00:29:22 +02:00
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
/* NT: ERROR_INVALID_PARAMETER, 9x: ERROR_PRIVILEGE_NOT_HELD */
|
|
|
|
ok( !res &&
|
|
|
|
((GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
(GetLastError() == ERROR_PRIVILEGE_NOT_HELD)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
|
2006-04-10 00:29:22 +02:00
|
|
|
"ERROR_PRIVILEGE_NOT_HELD)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
2006-07-12 23:31:46 +02:00
|
|
|
mi2a.pDLLName = empty;
|
2006-04-10 00:29:22 +02:00
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
2006-10-13 13:20:32 +02:00
|
|
|
"returned %d with %d (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
2006-04-10 00:29:22 +02:00
|
|
|
res, GetLastError());
|
|
|
|
|
2006-07-12 23:31:46 +02:00
|
|
|
mi2a.pDLLName = does_not_exist_dll;
|
2006-04-10 00:29:22 +02:00
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
/* NT: ERROR_MOD_NOT_FOUND, 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res &&
|
|
|
|
((GetLastError() == ERROR_MOD_NOT_FOUND) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: ERROR_MOD_NOT_FOUND or "
|
2006-04-10 00:29:22 +02:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
2006-07-12 23:31:46 +02:00
|
|
|
mi2a.pDLLName = version_dll;
|
2006-04-10 00:29:22 +02:00
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
/* NT: ERROR_PROC_NOT_FOUND, 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res &&
|
|
|
|
((GetLastError() == ERROR_PROC_NOT_FOUND) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: ERROR_PROC_NOT_FOUND or "
|
2006-04-10 00:29:22 +02:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
2007-01-15 05:37:14 +01:00
|
|
|
if (res) DeleteMonitorA(NULL, entry->env, winetest);
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
/* Test AddMonitor with real options */
|
|
|
|
mi2a.pDLLName = entry->dllname;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
2017-02-08 10:03:45 +01:00
|
|
|
/* Some apps depend on the result of GetLastError() also on success of AddMonitor */
|
|
|
|
ok(res && (GetLastError() == ERROR_SUCCESS),
|
|
|
|
"returned %d with %d (expected '!= 0' with ERROR_SUCCESS)\n", res, GetLastError());
|
2006-07-12 23:31:46 +02:00
|
|
|
|
2006-04-10 00:29:22 +02:00
|
|
|
/* add a monitor twice */
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
/* NT: ERROR_PRINT_MONITOR_ALREADY_INSTALLED (3006), 9x: ERROR_ALREADY_EXISTS (183) */
|
|
|
|
ok( !res &&
|
|
|
|
((GetLastError() == ERROR_PRINT_MONITOR_ALREADY_INSTALLED) ||
|
|
|
|
(GetLastError() == ERROR_ALREADY_EXISTS)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: "
|
2006-04-10 00:29:22 +02:00
|
|
|
"ERROR_PRINT_MONITOR_ALREADY_INSTALLED or ERROR_ALREADY_EXISTS)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
2007-01-15 05:37:14 +01:00
|
|
|
DeleteMonitorA(NULL, entry->env, winetest);
|
2006-04-10 00:29:22 +02:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
res = AddMonitorA(empty, 2, (LPBYTE) &mi2a);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
/* cleanup */
|
2007-01-15 05:37:14 +01:00
|
|
|
DeleteMonitorA(NULL, entry->env, winetest);
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-04-16 02:42:34 +02:00
|
|
|
/* ########################### */
|
|
|
|
|
2006-11-28 00:50:57 +01:00
|
|
|
static void test_AddPort(void)
|
|
|
|
{
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = AddPortA(NULL, 0, NULL);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2006-11-28 00:50:57 +01:00
|
|
|
/* NT: RPC_X_NULL_REF_POINTER, 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res && ((GetLastError() == RPC_X_NULL_REF_POINTER) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
|
2006-11-28 00:50:57 +01:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = AddPortA(NULL, 0, empty);
|
|
|
|
/* Allowed only for (Printer-)Administrators */
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_access_denied(res, GetLastError())) return;
|
2007-08-13 12:07:57 +02:00
|
|
|
|
2006-11-28 00:50:57 +01:00
|
|
|
/* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
|
2006-11-28 00:50:57 +01:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = AddPortA(NULL, 0, does_not_exist);
|
|
|
|
/* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
|
2006-11-28 00:50:57 +01:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
2007-06-18 00:58:49 +02:00
|
|
|
static void test_AddPortEx(void)
|
|
|
|
{
|
|
|
|
PORT_INFO_2A pi;
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
|
|
|
|
if (!pAddPortExA) {
|
2009-02-25 10:30:13 +01:00
|
|
|
win_skip("AddPortEx not supported\n");
|
2007-06-18 00:58:49 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start test with a clean system */
|
|
|
|
DeletePortA(NULL, 0, tempfileA);
|
|
|
|
|
|
|
|
pi.pPortName = tempfileA;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pAddPortExA(NULL, 1, (LPBYTE) &pi, LocalPortA);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2007-06-18 00:58:49 +02:00
|
|
|
|
|
|
|
/* Allowed only for (Printer-)Administrators.
|
|
|
|
W2K+XP: ERROR_INVALID_PARAMETER */
|
|
|
|
if (!res && (GetLastError() == ERROR_INVALID_PARAMETER)) {
|
|
|
|
skip("ACCESS_DENIED (ERROR_INVALID_PARAMETER)\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok( res, "got %u with %u (expected '!= 0')\n", res, GetLastError());
|
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* add a port that already exists */
|
2007-06-18 00:58:49 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pAddPortExA(NULL, 1, (LPBYTE) &pi, LocalPortA);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
DeletePortA(NULL, 0, tempfileA);
|
|
|
|
|
|
|
|
|
|
|
|
/* the Monitorname must match */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pAddPortExA(NULL, 1, (LPBYTE) &pi, NULL);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
if (res) DeletePortA(NULL, 0, tempfileA);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pAddPortExA(NULL, 1, (LPBYTE) &pi, empty);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
if (res) DeletePortA(NULL, 0, tempfileA);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pAddPortExA(NULL, 1, (LPBYTE) &pi, does_not_exist);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
if (res) DeletePortA(NULL, 0, tempfileA);
|
|
|
|
|
|
|
|
|
|
|
|
/* We need a Portname */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pAddPortExA(NULL, 1, NULL, LocalPortA);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
pi.pPortName = NULL;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pAddPortExA(NULL, 1, (LPBYTE) &pi, LocalPortA);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
if (res) DeletePortA(NULL, 0, tempfileA);
|
|
|
|
|
|
|
|
|
|
|
|
/* level 2 is documented as supported for Printmonitors,
|
|
|
|
but that is not supported for "Local Port" (localspl.dll) and
|
|
|
|
AddPortEx fails with ERROR_INVALID_LEVEL */
|
|
|
|
|
|
|
|
pi.pPortName = tempfileA;
|
|
|
|
pi.pMonitorName = LocalPortA;
|
|
|
|
pi.pDescription = winetest;
|
|
|
|
pi.fPortType = PORT_TYPE_WRITE;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pAddPortExA(NULL, 2, (LPBYTE) &pi, LocalPortA);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
if (res) DeletePortA(NULL, 0, tempfileA);
|
|
|
|
|
|
|
|
|
|
|
|
/* invalid levels */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pAddPortExA(NULL, 0, (LPBYTE) &pi, LocalPortA);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pAddPortExA(NULL, 3, (LPBYTE) &pi, LocalPortA);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
DeletePortA(NULL, 0, tempfileA);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
2006-11-07 00:07:48 +01:00
|
|
|
static void test_ConfigurePort(void)
|
|
|
|
{
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ConfigurePortA(NULL, 0, NULL);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2006-11-07 00:07:48 +01:00
|
|
|
/* NT: RPC_X_NULL_REF_POINTER, 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res && ((GetLastError() == RPC_X_NULL_REF_POINTER) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
|
2006-11-07 00:07:48 +01:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ConfigurePortA(NULL, 0, empty);
|
|
|
|
/* Allowed only for (Printer-)Administrators */
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_access_denied(res, GetLastError())) return;
|
2007-08-13 12:07:57 +02:00
|
|
|
|
2006-11-07 00:07:48 +01:00
|
|
|
/* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
|
2006-11-07 00:07:48 +01:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ConfigurePortA(NULL, 0, does_not_exist);
|
|
|
|
/* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
|
2006-11-07 00:07:48 +01:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
/* Testing-Results:
|
|
|
|
- Case of Portnames is ignored
|
|
|
|
- Portname without ":" => NT: ERROR_NOT_SUPPORTED, 9x: Dialog comes up
|
|
|
|
- Empty Servername (LPT1:) => NT: ERROR_NOT_SUPPORTED, 9x: Dialog comes up
|
|
|
|
|
|
|
|
- Port not present => 9x: ERROR_INVALID_PARAMETER, NT:ERROR_NOT_SUPPORTED
|
|
|
|
- "FILE:" => 9x:Success, NT:ERROR_CANCELED
|
|
|
|
- Cancel ("Local Port") => ERROR_CANCELED
|
|
|
|
- Cancel ("Redirected Port") => Success
|
|
|
|
*/
|
|
|
|
if (winetest_interactive > 0) {
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ConfigurePortA(NULL, 0, portname_com1);
|
|
|
|
trace("'%s' returned %d with %d\n", portname_com1, res, GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ConfigurePortA(NULL, 0, portname_lpt1);
|
|
|
|
trace("'%s' returned %d with %d\n", portname_lpt1, res, GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ConfigurePortA(NULL, 0, portname_file);
|
|
|
|
trace("'%s' returned %d with %d\n", portname_file, res, GetLastError());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
2016-11-01 23:21:42 +01:00
|
|
|
static void test_ClosePrinter(void)
|
|
|
|
{
|
|
|
|
HANDLE printer = 0;
|
|
|
|
BOOL res;
|
|
|
|
|
|
|
|
/* NULL is handled */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ClosePrinter(NULL);
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_HANDLE),
|
|
|
|
"got %d with %d (expected FALSE with ERROR_INVALID_HANDLE)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
/* A random value as HANDLE is handled */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ClosePrinter( (void *) -1);
|
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_HANDLE),
|
|
|
|
"got %d with %d (expected FALSE with ERROR_INVALID_HANDLE)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
/* Normal use (The Spooler service is needed) */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = OpenPrinterA(default_printer, &printer, NULL);
|
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ClosePrinter(printer);
|
|
|
|
ok(res, "got %d with %d (expected TRUE)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
/* double free is handled */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ClosePrinter(printer);
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_HANDLE),
|
|
|
|
"got %d with %d (expected FALSE with ERROR_INVALID_HANDLE)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
2006-04-16 02:42:34 +02:00
|
|
|
static void test_DeleteMonitor(void)
|
|
|
|
{
|
2006-08-19 17:15:59 +02:00
|
|
|
MONITOR_INFO_2A mi2a;
|
|
|
|
struct monitor_entry * entry = NULL;
|
|
|
|
DWORD res;
|
2006-09-10 19:01:30 +02:00
|
|
|
|
2006-04-16 02:42:34 +02:00
|
|
|
|
|
|
|
entry = find_installed_monitor();
|
|
|
|
|
|
|
|
if (!entry) {
|
2007-03-05 21:44:18 +01:00
|
|
|
skip("No usable Monitor found\n");
|
2006-04-16 02:42:34 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-15 05:37:14 +01:00
|
|
|
mi2a.pName = winetest;
|
2006-04-16 02:42:34 +02:00
|
|
|
mi2a.pEnvironment = entry->env;
|
|
|
|
mi2a.pDLLName = entry->dllname;
|
|
|
|
|
|
|
|
/* Testing DeleteMonitor with real options */
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2007-01-15 05:37:14 +01:00
|
|
|
res = DeleteMonitorA(NULL, entry->env, winetest);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
|
2006-04-16 02:42:34 +02:00
|
|
|
|
|
|
|
/* Delete the Monitor twice */
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2007-01-15 05:37:14 +01:00
|
|
|
res = DeleteMonitorA(NULL, entry->env, winetest);
|
2006-04-16 02:42:34 +02:00
|
|
|
/* NT: ERROR_UNKNOWN_PRINT_MONITOR (3000), 9x: ERROR_INVALID_PARAMETER (87) */
|
|
|
|
ok( !res &&
|
|
|
|
((GetLastError() == ERROR_UNKNOWN_PRINT_MONITOR) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: ERROR_UNKNOWN_PRINT_MONITOR"
|
2006-04-16 02:42:34 +02:00
|
|
|
" or ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
/* the environment */
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2007-01-15 05:37:14 +01:00
|
|
|
res = DeleteMonitorA(NULL, NULL, winetest);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError());
|
2006-04-16 02:42:34 +02:00
|
|
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2007-01-15 05:37:14 +01:00
|
|
|
res = DeleteMonitorA(NULL, empty, winetest);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError());
|
2006-04-16 02:42:34 +02:00
|
|
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2007-01-15 05:37:14 +01:00
|
|
|
res = DeleteMonitorA(NULL, invalid_env, winetest);
|
2015-10-14 09:34:10 +02:00
|
|
|
ok( res || GetLastError() == ERROR_INVALID_ENVIRONMENT /* Vista/W2K8 */,
|
2008-09-05 16:19:34 +02:00
|
|
|
"returned %d with %d\n", res, GetLastError());
|
2006-04-16 02:42:34 +02:00
|
|
|
|
|
|
|
/* the monitor-name */
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = DeleteMonitorA(NULL, entry->env, NULL);
|
|
|
|
/* NT: ERROR_INVALID_PARAMETER (87), 9x: ERROR_INVALID_NAME (123)*/
|
|
|
|
ok( !res &&
|
|
|
|
((GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_NAME)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
|
2006-04-16 02:42:34 +02:00
|
|
|
"ERROR_INVALID_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
res = DeleteMonitorA(NULL, entry->env, empty);
|
2006-04-16 02:42:34 +02:00
|
|
|
/* NT: ERROR_INVALID_PARAMETER (87), 9x: ERROR_INVALID_NAME (123)*/
|
|
|
|
ok( !res &&
|
|
|
|
((GetLastError() == ERROR_INVALID_PARAMETER) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_NAME)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or "
|
2006-04-16 02:42:34 +02:00
|
|
|
"ERROR_INVALID_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2007-01-15 05:37:14 +01:00
|
|
|
res = DeleteMonitorA(empty, entry->env, winetest);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError());
|
2006-04-16 02:42:34 +02:00
|
|
|
|
|
|
|
/* cleanup */
|
2007-01-15 05:37:14 +01:00
|
|
|
DeleteMonitorA(NULL, entry->env, winetest);
|
2006-04-16 02:42:34 +02:00
|
|
|
}
|
|
|
|
|
2006-11-28 00:48:04 +01:00
|
|
|
/* ########################### */
|
|
|
|
|
|
|
|
static void test_DeletePort(void)
|
|
|
|
{
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = DeletePortA(NULL, 0, NULL);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2006-11-28 00:48:04 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = DeletePortA(NULL, 0, empty);
|
|
|
|
/* Allowed only for (Printer-)Administrators */
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_access_denied(res, GetLastError())) return;
|
2007-08-13 12:07:57 +02:00
|
|
|
|
2006-11-28 00:48:04 +01:00
|
|
|
/* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
|
2006-11-28 00:48:04 +01:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = DeletePortA(NULL, 0, does_not_exist);
|
|
|
|
/* XP: ERROR_NOT_SUPPORTED, NT351 and 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res && ((GetLastError() == ERROR_NOT_SUPPORTED) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with ERROR_NOT_SUPPORTED or "
|
2006-11-28 00:48:04 +01:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
2006-06-16 09:54:55 +02:00
|
|
|
|
|
|
|
static void test_EnumForms(LPSTR pName)
|
|
|
|
{
|
|
|
|
DWORD res;
|
|
|
|
HANDLE hprinter = 0;
|
|
|
|
LPBYTE buffer;
|
|
|
|
DWORD cbBuf;
|
|
|
|
DWORD pcbNeeded;
|
|
|
|
DWORD pcReturned;
|
|
|
|
DWORD level;
|
2008-01-01 14:06:47 +01:00
|
|
|
UINT i;
|
2007-12-09 19:50:56 +01:00
|
|
|
const char *formtype;
|
|
|
|
static const char * const formtypes[] = { "FORM_USER", "FORM_BUILTIN", "FORM_PRINTER", "FORM_flag_unknown" };
|
|
|
|
#define FORMTYPE_MAX 2
|
|
|
|
PFORM_INFO_1A pFI_1a;
|
|
|
|
PFORM_INFO_2A pFI_2a;
|
2006-06-16 09:54:55 +02:00
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(pName, &hprinter, NULL);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2006-06-16 09:54:55 +02:00
|
|
|
if (!res || !hprinter)
|
|
|
|
{
|
2012-06-24 19:40:56 +02:00
|
|
|
/* opening the local Printserver is not supported on win9x */
|
2007-03-05 21:44:18 +01:00
|
|
|
if (pName) skip("Failed to open '%s' (not supported on win9x)\n", pName);
|
2006-06-16 09:54:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* valid levels are 1 and 2 */
|
|
|
|
for(level = 0; level < 4; level++) {
|
|
|
|
cbBuf = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumFormsA(hprinter, level, NULL, 0, &cbBuf, &pcReturned);
|
2007-12-09 19:50:56 +01:00
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* EnumForms is not implemented on win9x */
|
2006-06-16 09:54:55 +02:00
|
|
|
if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
|
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* EnumForms for the server is not implemented on all NT-versions */
|
2006-06-16 09:54:55 +02:00
|
|
|
if (!res && (GetLastError() == ERROR_INVALID_HANDLE) && !pName) continue;
|
|
|
|
|
|
|
|
/* Level 2 for EnumForms is not supported on all systems */
|
|
|
|
if (!res && (GetLastError() == ERROR_INVALID_LEVEL) && (level == 2)) continue;
|
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* use only a short test when testing an invalid level */
|
2006-06-16 09:54:55 +02:00
|
|
|
if(!level || (level > 2)) {
|
|
|
|
ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
|
|
|
|
(res && (pcReturned == 0)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d and 0x%08x (expected '0' with "
|
2006-06-16 09:54:55 +02:00
|
|
|
"ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
|
|
|
|
level, res, GetLastError(), pcReturned);
|
|
|
|
continue;
|
2007-12-09 19:50:56 +01:00
|
|
|
}
|
2006-06-16 09:54:55 +02:00
|
|
|
|
|
|
|
ok((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-06-16 09:54:55 +02:00
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
|
|
|
|
if (buffer == NULL) continue;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumFormsA(hprinter, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "(%d) returned %d with %d (expected '!=0')\n",
|
2006-06-16 09:54:55 +02:00
|
|
|
level, res, GetLastError());
|
|
|
|
|
2021-05-19 15:43:13 +02:00
|
|
|
pFI_1a = (PFORM_INFO_1A)buffer;
|
|
|
|
pFI_2a = (PFORM_INFO_2A)buffer;
|
|
|
|
for (i = 0; i < pcReturned; i++)
|
|
|
|
{
|
|
|
|
/* first part is same in FORM_INFO_1 and FORM_INFO_2 */
|
|
|
|
formtype = (pFI_1a->Flags <= FORMTYPE_MAX) ? formtypes[pFI_1a->Flags] : formtypes[3];
|
|
|
|
if (winetest_debug > 1)
|
2007-12-09 19:50:56 +01:00
|
|
|
trace("%u (%s): %.03fmm x %.03fmm, %s\n", i, pFI_1a->pName,
|
|
|
|
(float)pFI_1a->Size.cx/1000, (float)pFI_1a->Size.cy/1000, formtype);
|
|
|
|
|
2021-05-19 15:43:13 +02:00
|
|
|
if (level == 1) pFI_1a++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BYTE get_buffer[1000];
|
|
|
|
FORM_INFO_2A *get_form = (FORM_INFO_2A *)get_buffer;
|
|
|
|
DWORD get_needed;
|
|
|
|
|
|
|
|
/* output additional FORM_INFO_2 fields */
|
|
|
|
if (winetest_debug > 1)
|
2007-12-09 19:50:56 +01:00
|
|
|
trace("\tkeyword=%s strtype=%u muidll=%s resid=%u dispname=%s langid=%u\n",
|
|
|
|
pFI_2a->pKeyword, pFI_2a->StringType, pFI_2a->pMuiDll,
|
|
|
|
pFI_2a->dwResourceId, pFI_2a->pDisplayName, pFI_2a->wLangId);
|
|
|
|
|
2021-05-19 15:43:13 +02:00
|
|
|
if (pName && i == 0) /* GetForm() appears only to work on a printer handle */
|
|
|
|
{
|
|
|
|
res = GetFormA( hprinter, pFI_1a->pName, level, NULL, 0, &get_needed );
|
|
|
|
ok( !res && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d gle %d\n", res, GetLastError() );
|
|
|
|
if (get_needed <= sizeof(get_buffer))
|
|
|
|
{
|
|
|
|
res = GetFormA( hprinter, pFI_1a->pName, level, get_buffer, get_needed, &get_needed );
|
|
|
|
ok( res, "got %d\n", res );
|
|
|
|
ok( !strcmp( pFI_2a->pName, get_form->pName ), "name mismatch\n" );
|
|
|
|
res = GetFormA( hprinter, pFI_1a->pName, level, get_buffer, get_needed - 1, &get_needed );
|
|
|
|
ok( !res && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d gle %d\n", res, GetLastError() );
|
|
|
|
}
|
2007-12-09 19:50:56 +01:00
|
|
|
}
|
2021-05-19 15:43:13 +02:00
|
|
|
/* offset pointer pFI_1a by 1*sizeof(FORM_INFO_2A) Bytes */
|
|
|
|
pFI_2a++;
|
|
|
|
pFI_1a = (PFORM_INFO_1A)pFI_2a;
|
2007-12-09 19:50:56 +01:00
|
|
|
}
|
|
|
|
}
|
2006-06-16 09:54:55 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumFormsA(hprinter, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok( res, "(%d) returned %d with %d (expected '!=0')\n",
|
2006-06-16 09:54:55 +02:00
|
|
|
level, res, GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumFormsA(hprinter, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-06-16 09:54:55 +02:00
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumFormsA(hprinter, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_USER_BUFFER) ,
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-06-16 09:54:55 +02:00
|
|
|
"ERROR_INVALID_USER_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumFormsA(hprinter, level, buffer, cbBuf, NULL, &pcReturned);
|
|
|
|
ok( !res && (GetLastError() == RPC_X_NULL_REF_POINTER) ,
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-06-16 09:54:55 +02:00
|
|
|
"RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumFormsA(hprinter, level, buffer, cbBuf, &pcbNeeded, NULL);
|
|
|
|
ok( !res && (GetLastError() == RPC_X_NULL_REF_POINTER) ,
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-06-16 09:54:55 +02:00
|
|
|
"RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumFormsA(0, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_HANDLE) ,
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-06-16 09:54:55 +02:00
|
|
|
"ERROR_INVALID_HANDLE)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
} /* for(level ... */
|
|
|
|
|
|
|
|
ClosePrinter(hprinter);
|
|
|
|
}
|
2006-04-16 02:42:34 +02:00
|
|
|
|
2006-02-17 17:37:04 +01:00
|
|
|
/* ########################### */
|
|
|
|
|
|
|
|
static void test_EnumMonitors(void)
|
|
|
|
{
|
|
|
|
DWORD res;
|
|
|
|
LPBYTE buffer;
|
|
|
|
DWORD cbBuf;
|
|
|
|
DWORD pcbNeeded;
|
|
|
|
DWORD pcReturned;
|
|
|
|
DWORD level;
|
|
|
|
|
|
|
|
/* valid levels are 1 and 2 */
|
|
|
|
for(level = 0; level < 4; level++) {
|
|
|
|
cbBuf = MAGIC_DEAD;
|
|
|
|
pcReturned = MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = EnumMonitorsA(NULL, level, NULL, 0, &cbBuf, &pcReturned);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2006-02-17 17:37:04 +01:00
|
|
|
/* not implemented yet in wine */
|
|
|
|
if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
|
|
|
|
|
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* use only a short test when testing an invalid level */
|
2006-02-17 17:37:04 +01:00
|
|
|
if(!level || (level > 2)) {
|
|
|
|
ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
|
|
|
|
(res && (pcReturned == 0)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d and 0x%08x (expected '0' with "
|
2006-02-17 17:37:04 +01:00
|
|
|
"ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
|
|
|
|
level, res, GetLastError(), pcReturned);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Level 2 is not supported on win9x */
|
|
|
|
if (!res && (GetLastError() == ERROR_INVALID_LEVEL)) {
|
2007-03-05 21:44:18 +01:00
|
|
|
skip("Level %d not supported\n", level);
|
2006-02-17 17:37:04 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-02-17 17:37:04 +01:00
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
if (!cbBuf) {
|
2007-03-05 21:44:18 +01:00
|
|
|
skip("no valid buffer size returned\n");
|
2006-02-17 17:37:04 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
|
|
|
|
if (buffer == NULL) continue;
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
res = EnumMonitorsA(NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "(%d) returned %d with %d (expected '!=0')\n",
|
2006-02-17 17:37:04 +01:00
|
|
|
level, res, GetLastError());
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n",
|
2006-02-17 17:37:04 +01:00
|
|
|
level, pcbNeeded, cbBuf);
|
|
|
|
/* We can validate the returned Data with the Registry here */
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
pcReturned = MAGIC_DEAD;
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
res = EnumMonitorsA(NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "(%d) returned %d with %d (expected '!=0')\n", level,
|
2006-02-17 17:37:04 +01:00
|
|
|
res, GetLastError());
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level,
|
2006-02-17 17:37:04 +01:00
|
|
|
pcbNeeded, cbBuf);
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
res = EnumMonitorsA(NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-02-17 17:37:04 +01:00
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level,
|
2006-02-17 17:37:04 +01:00
|
|
|
pcbNeeded, cbBuf);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Do not add the next test:
|
|
|
|
w2k+: RPC_X_NULL_REF_POINTER
|
|
|
|
NT3.5: ERROR_INVALID_USER_BUFFER
|
|
|
|
win9x: crash in winspool.drv
|
|
|
|
|
|
|
|
res = EnumMonitorsA(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
*/
|
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
pcReturned = MAGIC_DEAD;
|
|
|
|
res = EnumMonitorsA(NULL, level, buffer, cbBuf, NULL, &pcReturned);
|
2015-10-14 09:34:10 +02:00
|
|
|
ok( res || GetLastError() == RPC_X_NULL_REF_POINTER,
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '!=0' or '0' with "
|
2006-02-17 17:37:04 +01:00
|
|
|
"RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
pcReturned = MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = EnumMonitorsA(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
|
2015-10-14 09:34:10 +02:00
|
|
|
ok( res || GetLastError() == RPC_X_NULL_REF_POINTER,
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '!=0' or '0' with "
|
2006-02-17 17:37:04 +01:00
|
|
|
"RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
} /* for(level ... */
|
|
|
|
}
|
|
|
|
|
2006-11-04 00:28:08 +01:00
|
|
|
/* ########################### */
|
|
|
|
|
|
|
|
static void test_EnumPorts(void)
|
|
|
|
{
|
|
|
|
DWORD res;
|
|
|
|
DWORD level;
|
|
|
|
LPBYTE buffer;
|
|
|
|
DWORD cbBuf;
|
|
|
|
DWORD pcbNeeded;
|
|
|
|
DWORD pcReturned;
|
|
|
|
|
|
|
|
/* valid levels are 1 and 2 */
|
|
|
|
for(level = 0; level < 4; level++) {
|
|
|
|
|
|
|
|
cbBuf = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumPortsA(NULL, level, NULL, 0, &cbBuf, &pcReturned);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2006-11-04 00:28:08 +01:00
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* use only a short test when testing an invalid level */
|
2006-11-04 00:28:08 +01:00
|
|
|
if(!level || (level > 2)) {
|
|
|
|
/* NT: ERROR_INVALID_LEVEL, 9x: success */
|
|
|
|
ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
|
|
|
|
(res && (pcReturned == 0)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d and 0x%08x (expected '0' with "
|
2006-11-04 00:28:08 +01:00
|
|
|
"ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
|
|
|
|
level, res, GetLastError(), pcReturned);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Level 2 is not supported on NT 3.x */
|
|
|
|
if (!res && (GetLastError() == ERROR_INVALID_LEVEL)) {
|
2007-03-05 21:44:18 +01:00
|
|
|
skip("Level %d not supported\n", level);
|
2006-11-04 00:28:08 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-11-04 00:28:08 +01:00
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf *2);
|
|
|
|
if (buffer == NULL) continue;
|
|
|
|
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumPortsA(NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
ok(res, "(%d) returned %d with %d (expected '!=0')\n", level, res, GetLastError());
|
|
|
|
ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level, pcbNeeded, cbBuf);
|
|
|
|
/* ToDo: Compare the returned Data with the Registry / "win.ini",[Ports] here */
|
|
|
|
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumPortsA(NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
|
|
|
|
ok(res, "(%d) returned %d with %d (expected '!=0')\n", level, res, GetLastError());
|
|
|
|
ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level, pcbNeeded, cbBuf);
|
|
|
|
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumPortsA(NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-11-04 00:28:08 +01:00
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", level, res, GetLastError());
|
|
|
|
ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level, pcbNeeded, cbBuf);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Do not add this test:
|
|
|
|
res = EnumPortsA(NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
w2k+: RPC_X_NULL_REF_POINTER
|
|
|
|
NT3.5: ERROR_INVALID_USER_BUFFER
|
|
|
|
win9x: crash in winspool.drv
|
|
|
|
*/
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = EnumPortsA(NULL, level, buffer, cbBuf, NULL, &pcReturned);
|
2006-11-04 00:28:08 +01:00
|
|
|
/* NT: RPC_X_NULL_REF_POINTER (1780), 9x: success */
|
|
|
|
ok( (!res && (GetLastError() == RPC_X_NULL_REF_POINTER) ) ||
|
|
|
|
( res && (GetLastError() == ERROR_SUCCESS) ),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-11-04 00:28:08 +01:00
|
|
|
"RPC_X_NULL_REF_POINTER or '!=0' with NO_ERROR)\n",
|
|
|
|
level, res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = EnumPortsA(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
|
2006-11-04 00:28:08 +01:00
|
|
|
/* NT: RPC_X_NULL_REF_POINTER (1780), 9x: success */
|
|
|
|
ok( (!res && (GetLastError() == RPC_X_NULL_REF_POINTER) ) ||
|
|
|
|
( res && (GetLastError() == ERROR_SUCCESS) ),
|
2006-12-27 00:19:17 +01:00
|
|
|
"(%d) returned %d with %d (expected '0' with "
|
2006-11-04 00:28:08 +01:00
|
|
|
"RPC_X_NULL_REF_POINTER or '!=0' with NO_ERROR)\n",
|
|
|
|
level, res, GetLastError());
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
2005-11-15 17:51:45 +01:00
|
|
|
|
2007-08-10 10:47:36 +02:00
|
|
|
static void test_EnumPrinterDrivers(void)
|
|
|
|
{
|
2009-03-24 10:27:01 +01:00
|
|
|
static char env_all[] = "all";
|
|
|
|
|
2007-08-10 10:47:36 +02:00
|
|
|
DWORD res;
|
|
|
|
LPBYTE buffer;
|
|
|
|
DWORD cbBuf;
|
|
|
|
DWORD pcbNeeded;
|
|
|
|
DWORD pcReturned;
|
|
|
|
DWORD level;
|
|
|
|
|
|
|
|
/* 1-3 for w95/w98/NT4; 1-3+6 for me; 1-6 for w2k/xp/2003; 1-6+8 for vista */
|
|
|
|
for(level = 0; level < 10; level++) {
|
|
|
|
cbBuf = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumPrinterDriversA(NULL, NULL, level, NULL, 0, &cbBuf, &pcReturned);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2007-08-10 10:47:36 +02:00
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* use only a short test when testing an invalid level */
|
2007-08-10 10:47:36 +02:00
|
|
|
if(!level || (level == 7) || (level > 8)) {
|
|
|
|
|
|
|
|
ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
|
|
|
|
(res && (pcReturned == 0)),
|
|
|
|
"(%d) got %u with %u and 0x%x "
|
|
|
|
"(expected '0' with ERROR_INVALID_LEVEL or '!=0' and 0x0)\n",
|
|
|
|
level, res, GetLastError(), pcReturned);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* some levels are not supported on all windows versions */
|
2007-08-10 10:47:36 +02:00
|
|
|
if (!res && (GetLastError() == ERROR_INVALID_LEVEL)) {
|
|
|
|
skip("Level %d not supported\n", level);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok( ((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) ||
|
|
|
|
(res && (default_printer == NULL)),
|
|
|
|
"(%u) got %u with %u for %s (expected '0' with "
|
|
|
|
"ERROR_INSUFFICIENT_BUFFER or '!= 0' without a printer)\n",
|
|
|
|
level, res, GetLastError(), default_printer);
|
|
|
|
|
|
|
|
if (!cbBuf) {
|
|
|
|
skip("no valid buffer size returned\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-12-01 00:05:01 +01:00
|
|
|
/* EnumPrinterDriversA returns the same number of bytes as EnumPrinterDriversW */
|
2020-04-13 09:52:54 +02:00
|
|
|
if (pEnumPrinterDriversW)
|
2009-12-01 00:05:01 +01:00
|
|
|
{
|
|
|
|
DWORD double_needed;
|
|
|
|
DWORD double_returned;
|
|
|
|
pEnumPrinterDriversW(NULL, NULL, level, NULL, 0, &double_needed, &double_returned);
|
|
|
|
ok(double_needed == cbBuf, "level %d: EnumPrinterDriversA returned different size %d than EnumPrinterDriversW (%d)\n", level, cbBuf, double_needed);
|
|
|
|
}
|
|
|
|
|
2007-08-10 10:47:36 +02:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf + 4);
|
|
|
|
if (buffer == NULL) continue;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
res = EnumPrinterDriversA(NULL, NULL, level, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
ok(res, "(%u) got %u with %u (expected '!=0')\n", level, res, GetLastError());
|
|
|
|
ok(pcbNeeded == cbBuf, "(%d) returned %d (expected %d)\n", level, pcbNeeded, cbBuf);
|
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* validate the returned data here */
|
2007-08-10 10:47:36 +02:00
|
|
|
if (level > 1) {
|
|
|
|
LPDRIVER_INFO_2A di = (LPDRIVER_INFO_2A) buffer;
|
|
|
|
|
|
|
|
ok( strrchr(di->pDriverPath, '\\') != NULL,
|
|
|
|
"(%u) got %s for %s (expected a full path)\n",
|
|
|
|
level, di->pDriverPath, di->pName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
res = EnumPrinterDriversA(NULL, NULL, level, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
|
|
|
|
ok(res, "(%u) got %u with %u (expected '!=0')\n", level, res, GetLastError());
|
|
|
|
ok(pcbNeeded == cbBuf, "(%u) returned %u (expected %u)\n", level, pcbNeeded, cbBuf);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
res = EnumPrinterDriversA(NULL, NULL, level, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
"(%u) got %u with %u (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
|
|
|
|
level, res, GetLastError());
|
|
|
|
ok(pcbNeeded == cbBuf, "(%u) returned %u (expected %u)\n", level, pcbNeeded, cbBuf);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Do not add the next test:
|
|
|
|
NT: ERROR_INVALID_USER_BUFFER
|
|
|
|
win9x: crash or 100% CPU
|
|
|
|
|
|
|
|
res = EnumPrinterDriversA(NULL, NULL, level, NULL, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
*/
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
res = EnumPrinterDriversA(NULL, NULL, level, buffer, cbBuf, NULL, &pcReturned);
|
2015-10-14 09:34:10 +02:00
|
|
|
ok( res || GetLastError() == RPC_X_NULL_REF_POINTER,
|
2007-08-10 10:47:36 +02:00
|
|
|
"(%u) got %u with %u (expected '!=0' or '0' with "
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumPrinterDriversA(NULL, NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
|
2015-10-14 09:34:10 +02:00
|
|
|
ok( res || GetLastError() == RPC_X_NULL_REF_POINTER,
|
2007-08-10 10:47:36 +02:00
|
|
|
"(%u) got %u with %u (expected '!=0' or '0' with "
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", level, res, GetLastError());
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
} /* for(level ... */
|
2009-03-24 10:27:01 +01:00
|
|
|
|
|
|
|
pcbNeeded = 0;
|
|
|
|
pcReturned = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumPrinterDriversA(NULL, env_all, 1, NULL, 0, &pcbNeeded, &pcReturned);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
skip("no printer drivers found\n");
|
|
|
|
return;
|
|
|
|
}
|
2009-03-24 16:13:01 +01:00
|
|
|
if (GetLastError() == ERROR_INVALID_ENVIRONMENT)
|
|
|
|
{
|
|
|
|
win_skip("NT4 and below don't support the 'all' environment value\n");
|
|
|
|
return;
|
|
|
|
}
|
2009-03-24 10:27:01 +01:00
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "unexpected error %u\n", GetLastError());
|
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, pcbNeeded);
|
|
|
|
res = EnumPrinterDriversA(NULL, env_all, 1, buffer, pcbNeeded, &pcbNeeded, &pcReturned);
|
|
|
|
ok(res, "EnumPrinterDriversA failed %u\n", GetLastError());
|
2009-12-01 00:05:23 +01:00
|
|
|
if (res && pcReturned > 0)
|
|
|
|
{
|
2013-10-24 23:06:43 +02:00
|
|
|
DRIVER_INFO_1A *di_1 = (DRIVER_INFO_1A *)buffer;
|
2009-12-01 00:05:23 +01:00
|
|
|
ok((LPBYTE) di_1->pName == NULL || (LPBYTE) di_1->pName < buffer ||
|
|
|
|
(LPBYTE) di_1->pName >= (LPBYTE)(di_1 + pcReturned),
|
|
|
|
"Driver Information not in sequence; pName %p, top of data %p\n",
|
|
|
|
di_1->pName, di_1 + pcReturned);
|
|
|
|
}
|
2009-03-24 10:27:01 +01:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
2007-08-10 10:47:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
2009-10-14 23:50:49 +02:00
|
|
|
static void test_EnumPrintProcessors(void)
|
|
|
|
{
|
|
|
|
DWORD res;
|
|
|
|
LPBYTE buffer;
|
|
|
|
DWORD cbBuf;
|
|
|
|
DWORD pcbNeeded;
|
|
|
|
DWORD pcReturned;
|
|
|
|
|
|
|
|
|
|
|
|
cbBuf = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumPrintProcessorsA(NULL, NULL, 1, NULL, 0, &cbBuf, &pcReturned);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2009-10-14 23:50:49 +02:00
|
|
|
|
|
|
|
if (res && !cbBuf) {
|
|
|
|
skip("No Printprocessor installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok((!res) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf + 4);
|
|
|
|
if (buffer == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
ok(res, "got %u with %u (expected '!=0')\n", res, GetLastError());
|
2012-06-24 19:40:56 +02:00
|
|
|
/* validate the returned data here. */
|
2009-10-14 23:50:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf+1, &pcbNeeded, &pcReturned);
|
|
|
|
ok(res, "got %u with %u (expected '!=0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf-1, &pcbNeeded, &pcReturned);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
/* only level 1 is valid */
|
|
|
|
if (0) {
|
|
|
|
/* both tests crash on win98se */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
res = EnumPrintProcessorsA(NULL, NULL, 0, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
res = EnumPrintProcessorsA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_LEVEL)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* an empty environment is ignored */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
res = EnumPrintProcessorsA(NULL, empty, 1, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
ok(res, "got %u with %u (expected '!=0')\n", res, GetLastError());
|
|
|
|
|
|
|
|
/* the environment is checked */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
res = EnumPrintProcessorsA(NULL, invalid_env, 1, buffer, cbBuf, &pcbNeeded, &pcReturned);
|
2009-10-16 15:13:17 +02:00
|
|
|
/* NT5: ERROR_INVALID_ENVIRONMENT, NT4: res != 0, 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( broken(res) || /* NT4 */
|
|
|
|
(GetLastError() == ERROR_INVALID_ENVIRONMENT) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER),
|
2009-10-14 23:50:49 +02:00
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_ENVIRONMENT or "
|
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
/* failure-Codes for NULL */
|
2020-04-13 09:52:54 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
res = EnumPrintProcessorsA(NULL, NULL, 1, NULL, cbBuf, &pcbNeeded, &pcReturned);
|
|
|
|
todo_wine {
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_USER_BUFFER) ,
|
|
|
|
"got %u with %u (expected '0' with ERROR_INVALID_USER_BUFFER)\n",
|
|
|
|
res, GetLastError());
|
2009-10-14 23:50:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf, NULL, &pcReturned);
|
|
|
|
/* the NULL is ignored on win9x */
|
|
|
|
ok( broken(res) || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)),
|
|
|
|
"got %u with %u (expected '0' with RPC_X_NULL_REF_POINTER)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
pcbNeeded = 0xdeadbeef;
|
|
|
|
pcReturned = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = EnumPrintProcessorsA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded, NULL);
|
|
|
|
/* the NULL is ignored on win9x */
|
|
|
|
ok( broken(res) || (!res && (GetLastError() == RPC_X_NULL_REF_POINTER)),
|
|
|
|
"got %u with %u (expected '0' with RPC_X_NULL_REF_POINTER)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
2006-02-01 12:32:10 +01:00
|
|
|
static void test_GetDefaultPrinter(void)
|
2004-03-07 04:46:54 +01:00
|
|
|
{
|
|
|
|
BOOL retval;
|
|
|
|
DWORD exact = DEFAULT_PRINTER_SIZE;
|
|
|
|
DWORD size;
|
|
|
|
char buffer[DEFAULT_PRINTER_SIZE];
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
if (!pGetDefaultPrinterA) return;
|
2004-03-07 04:46:54 +01:00
|
|
|
/* only supported on NT like OSes starting with win2k */
|
|
|
|
|
2004-06-14 18:54:42 +02:00
|
|
|
SetLastError(ERROR_SUCCESS);
|
2005-12-12 13:02:15 +01:00
|
|
|
retval = pGetDefaultPrinterA(buffer, &exact);
|
2019-09-30 01:39:57 +02:00
|
|
|
if (!retval || !exact || !*buffer ||
|
2004-06-14 18:54:42 +02:00
|
|
|
(ERROR_SUCCESS != GetLastError())) {
|
2004-06-15 22:25:24 +02:00
|
|
|
if ((ERROR_FILE_NOT_FOUND == GetLastError()) ||
|
|
|
|
(ERROR_INVALID_NAME == GetLastError()))
|
2004-06-14 18:54:42 +02:00
|
|
|
trace("this test requires a default printer to be set\n");
|
|
|
|
else {
|
|
|
|
ok( 0, "function call GetDefaultPrinterA failed unexpected!\n"
|
2004-03-07 04:46:54 +01:00
|
|
|
"function returned %s\n"
|
2006-10-13 13:20:32 +02:00
|
|
|
"last error 0x%08x\n"
|
|
|
|
"returned buffer size 0x%08x\n"
|
2004-03-07 04:46:54 +01:00
|
|
|
"returned buffer content %s\n",
|
2004-06-14 18:54:42 +02:00
|
|
|
retval ? "true" : "false", GetLastError(), exact, buffer);
|
|
|
|
}
|
2004-03-07 04:46:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2005-12-12 13:02:15 +01:00
|
|
|
retval = pGetDefaultPrinterA(NULL, NULL);
|
2004-03-07 04:46:54 +01:00
|
|
|
ok( !retval, "function result wrong! False expected\n");
|
|
|
|
ok( ERROR_INVALID_PARAMETER == GetLastError(),
|
2006-10-13 13:20:32 +02:00
|
|
|
"Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08x\n",
|
2004-03-07 04:46:54 +01:00
|
|
|
GetLastError());
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2005-12-12 13:02:15 +01:00
|
|
|
retval = pGetDefaultPrinterA(buffer, NULL);
|
2004-03-07 04:46:54 +01:00
|
|
|
ok( !retval, "function result wrong! False expected\n");
|
|
|
|
ok( ERROR_INVALID_PARAMETER == GetLastError(),
|
2006-10-13 13:20:32 +02:00
|
|
|
"Last error wrong! ERROR_INVALID_PARAMETER expected, got 0x%08x\n",
|
2004-03-07 04:46:54 +01:00
|
|
|
GetLastError());
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
size = 0;
|
2005-12-12 13:02:15 +01:00
|
|
|
retval = pGetDefaultPrinterA(NULL, &size);
|
2004-03-07 04:46:54 +01:00
|
|
|
ok( !retval, "function result wrong! False expected\n");
|
|
|
|
ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
|
2006-10-13 13:20:32 +02:00
|
|
|
"Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08x\n",
|
2004-03-07 04:46:54 +01:00
|
|
|
GetLastError());
|
2006-10-13 13:20:32 +02:00
|
|
|
ok( size == exact, "Parameter size wrong! %d expected got %d\n",
|
2004-03-07 04:46:54 +01:00
|
|
|
exact, size);
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
size = DEFAULT_PRINTER_SIZE;
|
2005-12-12 13:02:15 +01:00
|
|
|
retval = pGetDefaultPrinterA(NULL, &size);
|
2004-03-07 04:46:54 +01:00
|
|
|
ok( !retval, "function result wrong! False expected\n");
|
|
|
|
ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
|
2006-10-13 13:20:32 +02:00
|
|
|
"Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08x\n",
|
2004-03-07 04:46:54 +01:00
|
|
|
GetLastError());
|
2006-10-13 13:20:32 +02:00
|
|
|
ok( size == exact, "Parameter size wrong! %d expected got %d\n",
|
2004-03-07 04:46:54 +01:00
|
|
|
exact, size);
|
|
|
|
|
|
|
|
size = 0;
|
2005-12-12 13:02:15 +01:00
|
|
|
retval = pGetDefaultPrinterA(buffer, &size);
|
2004-03-07 04:46:54 +01:00
|
|
|
ok( !retval, "function result wrong! False expected\n");
|
|
|
|
ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
|
2006-10-13 13:20:32 +02:00
|
|
|
"Last error wrong! ERROR_INSUFFICIENT_BUFFER expected, got 0x%08x\n",
|
2004-03-07 04:46:54 +01:00
|
|
|
GetLastError());
|
2006-10-13 13:20:32 +02:00
|
|
|
ok( size == exact, "Parameter size wrong! %d expected got %d\n",
|
2004-03-07 04:46:54 +01:00
|
|
|
exact, size);
|
|
|
|
|
|
|
|
size = exact;
|
2005-12-12 13:02:15 +01:00
|
|
|
retval = pGetDefaultPrinterA(buffer, &size);
|
2004-03-07 04:46:54 +01:00
|
|
|
ok( retval, "function result wrong! True expected\n");
|
2006-10-13 13:20:32 +02:00
|
|
|
ok( size == exact, "Parameter size wrong! %d expected got %d\n",
|
2004-03-07 04:46:54 +01:00
|
|
|
exact, size);
|
|
|
|
}
|
|
|
|
|
2006-02-01 12:32:10 +01:00
|
|
|
static void test_GetPrinterDriverDirectory(void)
|
|
|
|
{
|
2006-08-19 17:15:59 +02:00
|
|
|
LPBYTE buffer = NULL;
|
|
|
|
DWORD cbBuf = 0, pcbNeeded = 0;
|
|
|
|
BOOL res;
|
2006-09-10 19:01:30 +02:00
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2004-06-16 22:07:02 +02:00
|
|
|
res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, 0, &cbBuf);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
|
|
|
|
2006-10-13 13:20:32 +02:00
|
|
|
trace("first call returned 0x%04x, with %d: buffer size 0x%08x\n",
|
2013-02-11 09:47:35 +01:00
|
|
|
res, GetLastError(), cbBuf);
|
2003-01-15 01:50:48 +01:00
|
|
|
|
2005-11-15 17:51:45 +01:00
|
|
|
ok((res == 0) && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with lasterror=%d (expected '0' with "
|
2005-11-15 17:51:45 +01:00
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", res, GetLastError());
|
|
|
|
|
2005-10-26 12:08:38 +02:00
|
|
|
if (!cbBuf) {
|
2007-03-05 21:44:18 +01:00
|
|
|
skip("no valid buffer size returned\n");
|
2005-10-26 12:08:38 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
buffer = HeapAlloc( GetProcessHeap(), 0, cbBuf*2);
|
2005-11-15 17:51:45 +01:00
|
|
|
if (buffer == NULL) return ;
|
2003-01-15 01:50:48 +01:00
|
|
|
|
|
|
|
res = GetPrinterDriverDirectoryA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded);
|
2004-01-23 03:10:33 +01:00
|
|
|
ok( res, "expected result != 0, got %d\n", res);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok( cbBuf == pcbNeeded, "pcbNeeded set to %d instead of %d\n",
|
2003-01-15 01:50:48 +01:00
|
|
|
pcbNeeded, cbBuf);
|
|
|
|
|
|
|
|
res = GetPrinterDriverDirectoryA(NULL, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
|
2004-01-23 03:10:33 +01:00
|
|
|
ok( res, "expected result != 0, got %d\n", res);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok( cbBuf == pcbNeeded, "pcbNeeded set to %d instead of %d\n",
|
2003-01-15 01:50:48 +01:00
|
|
|
pcbNeeded, cbBuf);
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2003-01-15 01:50:48 +01:00
|
|
|
res = GetPrinterDriverDirectoryA( NULL, NULL, 1, buffer, cbBuf-1, &pcbNeeded);
|
2004-01-23 03:10:33 +01:00
|
|
|
ok( !res , "expected result == 0, got %d\n", res);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok( cbBuf == pcbNeeded, "pcbNeeded set to %d instead of %d\n",
|
2003-01-15 01:50:48 +01:00
|
|
|
pcbNeeded, cbBuf);
|
2006-01-18 12:26:32 +01:00
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
ok( ERROR_INSUFFICIENT_BUFFER == GetLastError(),
|
2006-10-13 13:20:32 +02:00
|
|
|
"last error set to %d instead of ERROR_INSUFFICIENT_BUFFER\n",
|
2003-01-15 01:50:48 +01:00
|
|
|
GetLastError());
|
2006-01-18 12:26:32 +01:00
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
/*
|
|
|
|
Do not add the next test:
|
|
|
|
XPsp2: crash in this app, when the spooler is not running
|
|
|
|
NT3.5: ERROR_INVALID_USER_BUFFER
|
|
|
|
win9x: ERROR_INVALID_PARAMETER
|
|
|
|
|
|
|
|
pcbNeeded = MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2003-01-15 01:50:48 +01:00
|
|
|
res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, &pcbNeeded);
|
2006-02-02 13:50:36 +01:00
|
|
|
*/
|
2003-01-15 01:50:48 +01:00
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2003-01-15 01:50:48 +01:00
|
|
|
res = GetPrinterDriverDirectoryA( NULL, NULL, 1, buffer, cbBuf, NULL);
|
2012-06-20 22:24:11 +02:00
|
|
|
/* w7 with deactivated spooler: ERROR_INVALID_PARAMETER,
|
|
|
|
NT: RPC_X_NULL_REF_POINTER */
|
|
|
|
ok( res || (GetLastError() == RPC_X_NULL_REF_POINTER) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
"returned %d with %d (expected '!=0' or '0' with RPC_X_NULL_REF_POINTER "
|
|
|
|
"or '0' with ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
2003-01-15 01:50:48 +01:00
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2003-01-15 01:50:48 +01:00
|
|
|
res = GetPrinterDriverDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
|
2012-06-20 22:24:11 +02:00
|
|
|
/* w7 with deactivated spooler: ERROR_INVALID_PARAMETER,
|
|
|
|
NT: RPC_X_NULL_REF_POINTER */
|
|
|
|
ok( res || (GetLastError() == RPC_X_NULL_REF_POINTER) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
"returned %d with %d (expected '!=0' or '0' with RPC_X_NULL_REF_POINTER "
|
|
|
|
"or '0' with ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
2005-11-23 20:14:43 +01:00
|
|
|
/* with a valid buffer, but level is too large */
|
2005-11-15 17:51:45 +01:00
|
|
|
buffer[0] = '\0';
|
2006-02-02 13:50:36 +01:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2005-11-15 17:51:45 +01:00
|
|
|
res = GetPrinterDriverDirectoryA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded);
|
|
|
|
|
|
|
|
/* Level not checked in win9x and wine:*/
|
|
|
|
if((res != FALSE) && buffer[0])
|
|
|
|
{
|
2006-02-02 13:50:36 +01:00
|
|
|
trace("Level '2' not checked '%s'\n", buffer);
|
2005-11-15 17:51:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_LEVEL),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with lasterror=%d (expected '0' with "
|
2005-11-15 17:51:45 +01:00
|
|
|
"ERROR_INVALID_LEVEL)\n", res, GetLastError());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* printing environments are case insensitive */
|
|
|
|
/* "Windows 4.0" is valid for win9x and NT */
|
|
|
|
buffer[0] = '\0';
|
2006-02-02 13:50:36 +01:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2005-11-15 17:51:45 +01:00
|
|
|
res = GetPrinterDriverDirectoryA(NULL, env_win9x_case, 1,
|
|
|
|
buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
|
|
|
|
if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
|
|
|
cbBuf = pcbNeeded;
|
|
|
|
buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, cbBuf*2);
|
|
|
|
if (buffer == NULL) return ;
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2005-11-15 17:51:45 +01:00
|
|
|
res = GetPrinterDriverDirectoryA(NULL, env_win9x_case, 1,
|
|
|
|
buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
}
|
2006-01-18 12:26:32 +01:00
|
|
|
|
2006-12-27 00:19:17 +01:00
|
|
|
ok(res && buffer[0], "returned %d with "
|
2006-10-13 13:20:32 +02:00
|
|
|
"lasterror=%d and len=%d (expected '1' with 'len > 0')\n",
|
2005-11-15 17:51:45 +01:00
|
|
|
res, GetLastError(), lstrlenA((char *)buffer));
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
2006-02-02 13:50:36 +01:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2005-11-15 17:51:45 +01:00
|
|
|
res = GetPrinterDriverDirectoryA(NULL, env_x86, 1,
|
|
|
|
buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
|
|
|
|
if(!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
|
|
|
cbBuf = pcbNeeded;
|
|
|
|
buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, cbBuf*2);
|
|
|
|
if (buffer == NULL) return ;
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
2006-02-02 13:50:36 +01:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2005-11-15 17:51:45 +01:00
|
|
|
res = GetPrinterDriverDirectoryA(NULL, env_x86, 1,
|
|
|
|
buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* "Windows NT x86" is invalid for win9x */
|
|
|
|
ok( (res && buffer[0]) ||
|
|
|
|
(!res && (GetLastError() == ERROR_INVALID_ENVIRONMENT)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with lasterror=%d and len=%d (expected '!= 0' with "
|
2005-11-15 17:51:45 +01:00
|
|
|
"'len > 0' or '0' with ERROR_INVALID_ENVIRONMENT)\n",
|
|
|
|
res, GetLastError(), lstrlenA((char *)buffer));
|
|
|
|
|
2006-12-14 17:59:46 +01:00
|
|
|
/* A setup program (PDFCreator_0.8.0) use empty strings */
|
2006-02-01 12:32:10 +01:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
res = GetPrinterDriverDirectoryA(empty, empty, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError() );
|
2006-02-01 12:32:10 +01:00
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
res = GetPrinterDriverDirectoryA(NULL, empty, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError() );
|
2006-02-01 12:32:10 +01:00
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2006-08-19 17:15:59 +02:00
|
|
|
res = GetPrinterDriverDirectoryA(empty, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError() );
|
2006-02-01 12:32:10 +01:00
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, buffer);
|
|
|
|
}
|
|
|
|
|
2006-06-09 21:54:19 +02:00
|
|
|
/* ##### */
|
|
|
|
|
|
|
|
static void test_GetPrintProcessorDirectory(void)
|
|
|
|
{
|
2006-08-19 17:15:59 +02:00
|
|
|
LPBYTE buffer = NULL;
|
|
|
|
DWORD cbBuf = 0;
|
|
|
|
DWORD pcbNeeded = 0;
|
|
|
|
BOOL res;
|
2006-09-10 19:01:30 +02:00
|
|
|
|
2006-06-09 21:54:19 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, NULL, 1, NULL, 0, &cbBuf);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
|
|
|
|
2006-06-09 21:54:19 +02:00
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
2006-10-13 13:20:32 +02:00
|
|
|
"returned %d with %d (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
|
2006-06-09 21:54:19 +02:00
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, cbBuf*2);
|
|
|
|
if(buffer == NULL) return;
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, NULL, 1, buffer, cbBuf, &pcbNeeded);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
|
2006-06-09 21:54:19 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
buffer[0] = '\0';
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
|
2006-06-09 21:54:19 +02:00
|
|
|
|
2014-01-06 02:13:41 +01:00
|
|
|
/* Buffer too small */
|
2006-06-09 21:54:19 +02:00
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, buffer, cbBuf-1, &pcbNeeded);
|
|
|
|
ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
|
2006-10-13 13:20:32 +02:00
|
|
|
"returned %d with %d (expected '0' with ERROR_INSUFFICIENT_BUFFER)\n",
|
2006-06-09 21:54:19 +02:00
|
|
|
res, GetLastError());
|
|
|
|
|
2007-01-06 19:24:22 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2006-12-14 17:59:46 +01:00
|
|
|
/* XPsp2: the program will crash here, when the spooler is not running */
|
2006-06-09 21:54:19 +02:00
|
|
|
/* GetPrinterDriverDirectory has the same bug */
|
|
|
|
pcbNeeded = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, &pcbNeeded);
|
2009-10-16 14:56:34 +02:00
|
|
|
/* NT: ERROR_INVALID_USER_BUFFER, 9x: res != 0 */
|
|
|
|
ok( (!res && (GetLastError() == ERROR_INVALID_USER_BUFFER)) ||
|
|
|
|
broken(res),
|
|
|
|
"returned %d with %d (expected '0' with ERROR_INVALID_USER_BUFFER)\n",
|
|
|
|
res, GetLastError());
|
2007-01-06 19:24:22 +01:00
|
|
|
}
|
2006-06-09 21:54:19 +02:00
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, buffer, cbBuf, NULL);
|
2012-06-20 22:24:11 +02:00
|
|
|
/* w7 with deactivated spooler: ERROR_INVALID_PARAMETER,
|
|
|
|
NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
|
|
|
|
ok( !res && ((GetLastError() == RPC_X_NULL_REF_POINTER) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
|
|
|
"returned %d with %d (expected '0' with RPC_X_NULL_REF_POINTER "
|
|
|
|
"or with ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
2006-06-09 21:54:19 +02:00
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
|
2012-06-20 22:24:11 +02:00
|
|
|
/* w7 with deactivated spooler: ERROR_INVALID_PARAMETER,
|
|
|
|
NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
|
|
|
|
ok( !res && ((GetLastError() == RPC_X_NULL_REF_POINTER) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER)),
|
|
|
|
"returned %d with %d (expected '0' with RPC_X_NULL_REF_POINTER "
|
|
|
|
"or with ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
2006-06-09 21:54:19 +02:00
|
|
|
|
|
|
|
/* with a valid buffer, but level is invalid */
|
2009-10-16 14:56:34 +02:00
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, NULL, 0, buffer, cbBuf, &pcbNeeded);
|
|
|
|
/* Level is ignored in win9x*/
|
|
|
|
ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
|
|
|
|
broken(res && buffer[0]),
|
|
|
|
"returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
|
|
|
|
res, GetLastError());
|
|
|
|
|
2006-06-09 21:54:19 +02:00
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded);
|
2012-06-24 19:40:56 +02:00
|
|
|
/* Level is ignored on win9x*/
|
2009-10-16 14:56:34 +02:00
|
|
|
ok( (!res && (GetLastError() == ERROR_INVALID_LEVEL)) ||
|
|
|
|
broken(res && buffer[0]),
|
|
|
|
"returned %d with %d (expected '0' with ERROR_INVALID_LEVEL)\n",
|
|
|
|
res, GetLastError());
|
2006-06-09 21:54:19 +02:00
|
|
|
|
|
|
|
/* Empty environment is the same as the default environment */
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-08-19 17:15:59 +02:00
|
|
|
res = GetPrintProcessorDirectoryA(NULL, empty, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
|
2006-06-09 21:54:19 +02:00
|
|
|
|
|
|
|
/* "Windows 4.0" is valid for win9x and NT */
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, env_win9x_case, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
|
2006-06-09 21:54:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* "Windows NT x86" is invalid for win9x */
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, env_x86, 1, buffer, cbBuf*2, &pcbNeeded);
|
|
|
|
ok( res || (GetLastError() == ERROR_INVALID_ENVIRONMENT),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!= 0' or '0' with "
|
2006-06-09 21:54:19 +02:00
|
|
|
"ERROR_INVALID_ENVIRONMENT)\n", res, GetLastError());
|
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* invalid on all systems */
|
2006-06-09 21:54:19 +02:00
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-08-19 17:15:59 +02:00
|
|
|
res = GetPrintProcessorDirectoryA(NULL, invalid_env, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-06-09 21:54:19 +02:00
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_ENVIRONMENT),
|
2006-10-13 13:20:32 +02:00
|
|
|
"returned %d with %d (expected '0' with ERROR_INVALID_ENVIRONMENT)\n",
|
2006-06-09 21:54:19 +02:00
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
/* Empty servername is the same as the local computer */
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-08-19 17:15:59 +02:00
|
|
|
res = GetPrintProcessorDirectoryA(empty, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
|
2006-06-09 21:54:19 +02:00
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* invalid on all systems */
|
2006-06-09 21:54:19 +02:00
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-12-22 00:48:08 +01:00
|
|
|
res = GetPrintProcessorDirectoryA(server_does_not_exist, NULL, 1, buffer, cbBuf*2, &pcbNeeded);
|
2009-10-21 10:16:41 +02:00
|
|
|
ok( !res, "expected failure\n");
|
|
|
|
ok( GetLastError() == RPC_S_SERVER_UNAVAILABLE || /* NT */
|
|
|
|
GetLastError() == ERROR_INVALID_PARAMETER || /* 9x */
|
|
|
|
GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista */
|
|
|
|
"unexpected last error %d\n", GetLastError());
|
2006-06-09 21:54:19 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ##### */
|
|
|
|
|
2006-02-01 12:32:10 +01:00
|
|
|
static void test_OpenPrinter(void)
|
2005-12-12 13:02:15 +01:00
|
|
|
{
|
2006-08-19 17:15:59 +02:00
|
|
|
PRINTER_DEFAULTSA defaults;
|
|
|
|
HANDLE hprinter;
|
|
|
|
DWORD res;
|
2005-12-12 13:02:15 +01:00
|
|
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(NULL, NULL, NULL);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
2006-10-13 13:20:32 +02:00
|
|
|
"returned %d with %d (expected '0' with ERROR_INVALID_PARAMETER)\n",
|
2005-12-12 13:02:15 +01:00
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
/* Get Handle for the local Printserver (NT only)*/
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(NULL, &hprinter, NULL);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2015-10-14 09:34:10 +02:00
|
|
|
ok(res || GetLastError() == ERROR_INVALID_PARAMETER,
|
2006-10-13 13:20:32 +02:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with ERROR_INVALID_PARAMETER)\n",
|
2005-12-12 13:02:15 +01:00
|
|
|
res, GetLastError());
|
|
|
|
if(res) {
|
|
|
|
ClosePrinter(hprinter);
|
|
|
|
|
|
|
|
defaults.pDatatype=NULL;
|
|
|
|
defaults.pDevMode=NULL;
|
|
|
|
|
|
|
|
defaults.DesiredAccess=0;
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(NULL, &hprinter, &defaults);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError());
|
2005-12-12 13:02:15 +01:00
|
|
|
if (res) ClosePrinter(hprinter);
|
|
|
|
|
|
|
|
defaults.DesiredAccess=-1;
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(NULL, &hprinter, &defaults);
|
2006-05-11 19:57:48 +02:00
|
|
|
todo_wine {
|
2005-12-12 13:02:15 +01:00
|
|
|
ok(!res && GetLastError() == ERROR_ACCESS_DENIED,
|
2006-10-13 13:20:32 +02:00
|
|
|
"returned %d with %d (expected '0' with ERROR_ACCESS_DENIED)\n",
|
2005-12-12 13:02:15 +01:00
|
|
|
res, GetLastError());
|
2006-05-11 19:57:48 +02:00
|
|
|
}
|
2005-12-12 13:02:15 +01:00
|
|
|
if (res) ClosePrinter(hprinter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-22 00:48:16 +01:00
|
|
|
if (local_server != NULL) {
|
|
|
|
hprinter = (HANDLE) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(local_server, &hprinter, NULL);
|
2015-10-14 09:34:10 +02:00
|
|
|
ok(res || GetLastError() == ERROR_INVALID_PARAMETER,
|
2006-10-13 13:20:32 +02:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with ERROR_INVALID_PARAMETER)\n",
|
2005-12-12 13:02:15 +01:00
|
|
|
res, GetLastError());
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Invalid Printername */
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(illegal_name, &hprinter, NULL);
|
2005-12-12 13:02:15 +01:00
|
|
|
ok(!res && ((GetLastError() == ERROR_INVALID_PRINTER_NAME) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER) ),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: ERROR_INVALID_PARAMETER or"
|
2005-12-12 13:02:15 +01:00
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
2006-05-11 19:57:48 +02:00
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(empty, &hprinter, NULL);
|
2006-05-11 19:57:48 +02:00
|
|
|
/* NT: ERROR_INVALID_PRINTER_NAME, 9x: ERROR_INVALID_PARAMETER */
|
|
|
|
ok( !res &&
|
|
|
|
((GetLastError() == ERROR_INVALID_PRINTER_NAME) ||
|
|
|
|
(GetLastError() == ERROR_INVALID_PARAMETER) ),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with: ERROR_INVALID_PRINTER_NAME"
|
2006-05-11 19:57:48 +02:00
|
|
|
" or ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* get handle for the default printer */
|
2006-12-12 10:22:32 +01:00
|
|
|
if (default_printer)
|
2005-12-12 13:02:15 +01:00
|
|
|
{
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(default_printer, &hprinter, NULL);
|
2006-02-02 13:50:36 +01:00
|
|
|
if((!res) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE))
|
|
|
|
{
|
2012-06-24 19:40:56 +02:00
|
|
|
trace("The service 'Spooler' is required for '%s'\n", default_printer);
|
2006-02-02 13:50:36 +01:00
|
|
|
return;
|
|
|
|
}
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(res, "returned %d with %d (expected '!=0')\n", res, GetLastError());
|
2005-12-12 13:02:15 +01:00
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
2006-05-11 19:57:48 +02:00
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(default_printer, NULL, NULL);
|
2006-05-11 19:57:48 +02:00
|
|
|
/* NT: FALSE with ERROR_INVALID_PARAMETER, 9x: TRUE */
|
|
|
|
ok(res || (GetLastError() == ERROR_INVALID_PARAMETER),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-05-11 19:57:48 +02:00
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError());
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
defaults.pDatatype=NULL;
|
|
|
|
defaults.pDevMode=NULL;
|
|
|
|
defaults.DesiredAccess=0;
|
|
|
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(default_printer, &hprinter, &defaults);
|
2006-02-02 13:50:36 +01:00
|
|
|
ok(res || GetLastError() == ERROR_ACCESS_DENIED,
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-02-02 13:50:36 +01:00
|
|
|
"ERROR_ACCESS_DENIED)\n", res, GetLastError());
|
2005-12-12 13:02:15 +01:00
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
2006-07-12 23:31:46 +02:00
|
|
|
defaults.pDatatype = empty;
|
2005-12-12 13:02:15 +01:00
|
|
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(default_printer, &hprinter, &defaults);
|
2006-02-23 16:03:32 +01:00
|
|
|
/* stop here, when a remote Printserver has no RPC-Service running */
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2006-02-02 13:50:36 +01:00
|
|
|
ok(res || ((GetLastError() == ERROR_INVALID_DATATYPE) ||
|
|
|
|
(GetLastError() == ERROR_ACCESS_DENIED)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with: "
|
2006-02-02 13:50:36 +01:00
|
|
|
"ERROR_INVALID_DATATYPE or ERROR_ACCESS_DENIED)\n",
|
2005-12-12 13:02:15 +01:00
|
|
|
res, GetLastError());
|
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
|
|
|
|
|
|
|
defaults.pDatatype=NULL;
|
|
|
|
defaults.DesiredAccess=PRINTER_ACCESS_USE;
|
|
|
|
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(default_printer, &hprinter, &defaults);
|
2006-02-02 13:50:36 +01:00
|
|
|
ok(res || GetLastError() == ERROR_ACCESS_DENIED,
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-02-02 13:50:36 +01:00
|
|
|
"ERROR_ACCESS_DENIED)\n", res, GetLastError());
|
2005-12-12 13:02:15 +01:00
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
|
|
|
|
|
|
|
|
defaults.DesiredAccess=PRINTER_ALL_ACCESS;
|
|
|
|
hprinter = (HANDLE) MAGIC_DEAD;
|
|
|
|
SetLastError(MAGIC_DEAD);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(default_printer, &hprinter, &defaults);
|
2006-02-02 13:50:36 +01:00
|
|
|
ok(res || GetLastError() == ERROR_ACCESS_DENIED,
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-02-02 13:50:36 +01:00
|
|
|
"ERROR_ACCESS_DENIED)\n", res, GetLastError());
|
2005-12-12 13:02:15 +01:00
|
|
|
if(res) ClosePrinter(hprinter);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-02-20 11:51:10 +01:00
|
|
|
|
|
|
|
static void test_SetDefaultPrinter(void)
|
|
|
|
{
|
|
|
|
DWORD res;
|
|
|
|
DWORD size = DEFAULT_PRINTER_SIZE;
|
|
|
|
CHAR buffer[DEFAULT_PRINTER_SIZE];
|
|
|
|
CHAR org_value[DEFAULT_PRINTER_SIZE];
|
|
|
|
|
2010-11-11 08:47:07 +01:00
|
|
|
if (!default_printer)
|
|
|
|
{
|
|
|
|
skip("There is no default printer installed\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-02-20 11:51:10 +01:00
|
|
|
|
|
|
|
if (!pSetDefaultPrinterA) return;
|
2020-04-13 09:52:54 +02:00
|
|
|
/* only supported on win2k and above */
|
2006-02-20 11:51:10 +01:00
|
|
|
|
|
|
|
/* backup the original value */
|
|
|
|
org_value[0] = '\0';
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = GetProfileStringA("windows", "device", NULL, org_value, size);
|
2011-02-05 08:08:04 +01:00
|
|
|
ok(res, "GetProfileString error %d\n", GetLastError());
|
2006-02-20 11:51:10 +01:00
|
|
|
|
|
|
|
/* first part: with the default Printer */
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = pSetDefaultPrinterA("no_printer_with_this_name");
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
2006-02-20 11:51:10 +01:00
|
|
|
|
|
|
|
/* Not implemented in wine */
|
|
|
|
if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) {
|
|
|
|
trace("SetDefaultPrinterA() not implemented yet.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with "
|
2006-02-20 11:51:10 +01:00
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", org_value);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = pSetDefaultPrinterA("");
|
2015-10-14 09:34:10 +02:00
|
|
|
ok(res || GetLastError() == ERROR_INVALID_PRINTER_NAME,
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-02-20 11:51:10 +01:00
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", org_value);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = pSetDefaultPrinterA(NULL);
|
2015-10-14 09:34:10 +02:00
|
|
|
ok(res || GetLastError() == ERROR_INVALID_PRINTER_NAME,
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-02-20 11:51:10 +01:00
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", org_value);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = pSetDefaultPrinterA(default_printer);
|
2015-10-14 09:34:10 +02:00
|
|
|
ok(res || GetLastError() == ERROR_INVALID_PRINTER_NAME,
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-02-20 11:51:10 +01:00
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
/* second part: always without a default Printer */
|
|
|
|
WriteProfileStringA("windows", "device", NULL);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = pSetDefaultPrinterA("no_printer_with_this_name");
|
|
|
|
|
|
|
|
ok(!res && (GetLastError() == ERROR_INVALID_PRINTER_NAME),
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '0' with "
|
2006-02-20 11:51:10 +01:00
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", NULL);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = pSetDefaultPrinterA("");
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError()))
|
2012-06-20 22:24:11 +02:00
|
|
|
goto restore_old_printer;
|
|
|
|
|
2006-02-20 11:51:10 +01:00
|
|
|
/* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
|
2015-10-14 09:34:10 +02:00
|
|
|
ok(res || GetLastError() == ERROR_INVALID_PRINTER_NAME,
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-02-20 11:51:10 +01:00
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", NULL);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = pSetDefaultPrinterA(NULL);
|
|
|
|
/* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
|
2015-10-14 09:34:10 +02:00
|
|
|
ok(res || GetLastError() == ERROR_INVALID_PRINTER_NAME,
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-02-20 11:51:10 +01:00
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
WriteProfileStringA("windows", "device", NULL);
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = pSetDefaultPrinterA(default_printer);
|
2015-10-14 09:34:10 +02:00
|
|
|
ok(res || GetLastError() == ERROR_INVALID_PRINTER_NAME,
|
2006-12-27 00:19:17 +01:00
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-02-20 11:51:10 +01:00
|
|
|
"ERROR_INVALID_PRINTER_NAME)\n", res, GetLastError());
|
|
|
|
|
|
|
|
/* restore the original value */
|
2012-06-20 22:24:11 +02:00
|
|
|
restore_old_printer:
|
2006-02-20 11:51:10 +01:00
|
|
|
res = pSetDefaultPrinterA(default_printer); /* the nice way */
|
2011-02-05 08:08:04 +01:00
|
|
|
ok(res, "SetDefaultPrinter error %d\n", GetLastError());
|
2006-02-20 11:51:10 +01:00
|
|
|
WriteProfileStringA("windows", "device", org_value); /* the old way */
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
res = GetProfileStringA("windows", "device", NULL, buffer, size);
|
2011-02-05 08:08:04 +01:00
|
|
|
ok(res, "GetProfileString error %d\n", GetLastError());
|
2006-02-20 11:51:10 +01:00
|
|
|
ok(!lstrcmpA(org_value, buffer), "'%s' (expected '%s')\n", buffer, org_value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-02-02 00:46:03 +01:00
|
|
|
/* ########################### */
|
|
|
|
|
|
|
|
static void test_XcvDataW_MonitorUI(void)
|
|
|
|
{
|
|
|
|
DWORD res;
|
|
|
|
HANDLE hXcv;
|
|
|
|
BYTE buffer[MAX_PATH + 4];
|
|
|
|
DWORD needed;
|
|
|
|
DWORD status;
|
|
|
|
DWORD len;
|
|
|
|
PRINTER_DEFAULTSA pd;
|
|
|
|
|
|
|
|
/* api is not present before w2k */
|
|
|
|
if (pXcvDataW == NULL) return;
|
|
|
|
|
|
|
|
pd.pDatatype = NULL;
|
|
|
|
pd.pDevMode = NULL;
|
|
|
|
pd.DesiredAccess = SERVER_ACCESS_ADMINISTER;
|
|
|
|
|
|
|
|
hXcv = NULL;
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(xcv_localport, &hXcv, &pd);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
|
|
|
if (is_access_denied(res, GetLastError())) return;
|
2007-08-13 12:07:57 +02:00
|
|
|
|
2007-02-02 00:46:03 +01:00
|
|
|
ok(res, "returned %d with %u and handle %p (expected '!= 0')\n", res, GetLastError(), hXcv);
|
|
|
|
if (!res) return;
|
|
|
|
|
|
|
|
/* ask for needed size */
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"MonitorUI", NULL, 0, NULL, 0, &needed, &status);
|
2007-02-02 00:46:03 +01:00
|
|
|
ok( res && (status == ERROR_INSUFFICIENT_BUFFER) && (needed <= MAX_PATH),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' and "
|
|
|
|
"'<= MAX_PATH' for status ERROR_INSUFFICIENT_BUFFER)\n",
|
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
if (needed > MAX_PATH) {
|
|
|
|
ClosePrinter(hXcv);
|
|
|
|
skip("buffer overflow (%u)\n", needed);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
len = needed; /* Size is in bytes */
|
|
|
|
|
|
|
|
/* the command is required */
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"", NULL, 0, NULL, 0, &needed, &status);
|
2007-02-02 00:46:03 +01:00
|
|
|
ok( res && (status == ERROR_INVALID_PARAMETER),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' with "
|
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pXcvDataW(hXcv, NULL, NULL, 0, buffer, MAX_PATH, &needed, &status);
|
|
|
|
ok( !res && (GetLastError() == RPC_X_NULL_REF_POINTER),
|
|
|
|
"returned %d with %u and %u for status %u (expected '0' with "
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
/* "PDWORD needed" is checked before RPC-Errors */
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"MonitorUI", NULL, 0, buffer, len, NULL, &status);
|
2007-02-02 00:46:03 +01:00
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
"returned %d with %u and %u for status %u (expected '0' with "
|
|
|
|
"ERROR_INVALID_PARAMETER)\n", res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"MonitorUI", NULL, 0, NULL, len, &needed, &status);
|
2007-02-02 00:46:03 +01:00
|
|
|
ok( !res && (GetLastError() == RPC_X_NULL_REF_POINTER),
|
|
|
|
"returned %d with %u and %u for status %u (expected '0' with "
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"MonitorUI", NULL, 0, buffer, len, &needed, NULL);
|
2007-02-02 00:46:03 +01:00
|
|
|
ok( !res && (GetLastError() == RPC_X_NULL_REF_POINTER),
|
|
|
|
"returned %d with %u and %u for status %u (expected '0' with "
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
/* off by one: larger */
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"MonitorUI", NULL, 0, buffer, len+1, &needed, &status);
|
2007-02-02 00:46:03 +01:00
|
|
|
ok( res && (status == ERROR_SUCCESS),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' for status "
|
|
|
|
"ERROR_SUCCESS)\n", res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
/* off by one: smaller */
|
|
|
|
/* the buffer is not modified for NT4, w2k, XP */
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"MonitorUI", NULL, 0, buffer, len-1, &needed, &status);
|
2007-02-02 00:46:03 +01:00
|
|
|
ok( res && (status == ERROR_INSUFFICIENT_BUFFER),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' for status "
|
|
|
|
"ERROR_INSUFFICIENT_BUFFER)\n", res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
|
|
|
|
/* Normal use. The DLL-Name without a Path is returned */
|
|
|
|
memset(buffer, 0, len);
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"MonitorUI", NULL, 0, buffer, len, &needed, &status);
|
2007-02-02 00:46:03 +01:00
|
|
|
ok( res && (status == ERROR_SUCCESS),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' for status "
|
|
|
|
"ERROR_SUCCESS)\n", res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
ClosePrinter(hXcv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
2007-02-02 16:04:46 +01:00
|
|
|
static void test_XcvDataW_PortIsValid(void)
|
|
|
|
{
|
|
|
|
DWORD res;
|
|
|
|
HANDLE hXcv;
|
|
|
|
DWORD needed;
|
|
|
|
DWORD status;
|
|
|
|
PRINTER_DEFAULTSA pd;
|
|
|
|
|
|
|
|
/* api is not present before w2k */
|
|
|
|
if (pXcvDataW == NULL) return;
|
|
|
|
|
|
|
|
pd.pDatatype = NULL;
|
|
|
|
pd.pDevMode = NULL;
|
|
|
|
pd.DesiredAccess = SERVER_ACCESS_ADMINISTER;
|
|
|
|
|
2007-02-06 10:17:03 +01:00
|
|
|
hXcv = NULL;
|
2007-02-02 16:04:46 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(xcv_localport, &hXcv, &pd);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(res, GetLastError())) return;
|
|
|
|
if (is_access_denied(res, GetLastError())) return;
|
2007-08-13 12:07:57 +02:00
|
|
|
|
2007-02-02 16:04:46 +01:00
|
|
|
ok(res, "returned %d with %u and handle %p (expected '!= 0')\n", res, GetLastError(), hXcv);
|
|
|
|
if (!res) return;
|
|
|
|
|
|
|
|
|
|
|
|
/* "PDWORD needed" is always required */
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"PortIsValid", (BYTE *) L"LPT1:", sizeof(L"LPT1:"), NULL, 0, NULL, &status);
|
2007-02-02 16:04:46 +01:00
|
|
|
ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' with ERROR_INVALID_PARAMETER)\n",
|
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
/* an empty name is not allowed */
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"PortIsValid", (BYTE *) L"", sizeof(L""), NULL, 0, &needed, &status);
|
2007-03-05 21:44:18 +01:00
|
|
|
ok( res && ((status == ERROR_FILE_NOT_FOUND) || (status == ERROR_PATH_NOT_FOUND)),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' for status: "
|
|
|
|
"ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND)\n",
|
2007-02-02 16:04:46 +01:00
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
/* a directory is not allowed */
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"PortIsValid", (BYTE *) tempdirW, (lstrlenW(tempdirW) + 1) * sizeof(WCHAR),
|
|
|
|
NULL, 0, &needed, &status);
|
2007-02-02 16:04:46 +01:00
|
|
|
/* XP: ERROR_PATH_NOT_FOUND, w2k ERROR_ACCESS_DENIED */
|
|
|
|
ok( res && ((status == ERROR_PATH_NOT_FOUND) || (status == ERROR_ACCESS_DENIED)),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' for status: "
|
|
|
|
"ERROR_PATH_NOT_FOUND or ERROR_ACCESS_DENIED)\n",
|
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* more valid well known ports */
|
2007-02-02 16:04:46 +01:00
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"PortIsValid", (BYTE *) L"LPT1:", sizeof(L"LPT1:"), NULL, 0, &needed, &status);
|
2007-02-02 16:04:46 +01:00
|
|
|
ok( res && (status == ERROR_SUCCESS),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' for ERROR_SUCCESS)\n",
|
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"PortIsValid", (BYTE *) L"LPT2:", sizeof(L"LPT2:"), NULL, 0, &needed, &status);
|
2007-02-02 16:04:46 +01:00
|
|
|
ok( res && (status == ERROR_SUCCESS),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' for ERROR_SUCCESS)\n",
|
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"PortIsValid", (BYTE *) L"COM1:", sizeof(L"COM1:"), NULL, 0, &needed, &status);
|
2007-02-02 16:04:46 +01:00
|
|
|
ok( res && (status == ERROR_SUCCESS),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' for ERROR_SUCCESS)\n",
|
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"PortIsValid", (BYTE *) L"COM2:", sizeof(L"COM2:"), NULL, 0, &needed, &status);
|
2007-02-02 16:04:46 +01:00
|
|
|
ok( res && (status == ERROR_SUCCESS),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' for ERROR_SUCCESS)\n",
|
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"PortIsValid", (BYTE *) L"FILE:", sizeof(L"FILE:"), NULL, 0, &needed, &status);
|
2007-02-02 16:04:46 +01:00
|
|
|
ok( res && (status == ERROR_SUCCESS),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' with ERROR_SUCCESS)\n",
|
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
|
2007-02-14 16:22:07 +01:00
|
|
|
/* a normal, writable file is allowed */
|
2007-02-02 16:04:46 +01:00
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2020-12-19 21:17:01 +01:00
|
|
|
res = pXcvDataW(hXcv, L"PortIsValid", (BYTE *) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR),
|
|
|
|
NULL, 0, &needed, &status);
|
2007-02-02 16:04:46 +01:00
|
|
|
ok( res && (status == ERROR_SUCCESS),
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' with ERROR_SUCCESS)\n",
|
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
ClosePrinter(hXcv);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
2009-12-01 00:04:19 +01:00
|
|
|
static void test_GetPrinter(void)
|
|
|
|
{
|
|
|
|
HANDLE hprn;
|
|
|
|
BOOL ret;
|
|
|
|
BYTE *buf;
|
|
|
|
INT level;
|
|
|
|
DWORD needed, filled;
|
|
|
|
|
|
|
|
if (!default_printer)
|
|
|
|
{
|
|
|
|
skip("There is no default printer installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hprn = 0;
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = OpenPrinterA(default_printer, &hprn, NULL);
|
2009-12-01 00:04:19 +01:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
skip("Unable to open the default printer (%s)\n", default_printer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(hprn != 0, "wrong hprn %p\n", hprn);
|
|
|
|
|
|
|
|
for (level = 1; level <= 9; level++)
|
|
|
|
{
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
needed = (DWORD)-1;
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetPrinterA(hprn, level, NULL, 0, &needed);
|
2010-02-17 10:50:09 +01:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
win_skip("Level %d is not supported on Win9x/WinMe\n", level);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "wrong error %d\n", GetLastError());
|
|
|
|
ok(needed == 0,"Expected 0, got %d\n", needed);
|
|
|
|
continue;
|
|
|
|
}
|
2009-12-01 00:04:19 +01:00
|
|
|
ok(!ret, "level %d: GetPrinter should fail\n", level);
|
|
|
|
/* Not all levels are supported on all Windows-Versions */
|
2010-02-17 10:38:31 +01:00
|
|
|
if (GetLastError() == ERROR_INVALID_LEVEL ||
|
|
|
|
GetLastError() == ERROR_NOT_SUPPORTED /* Win9x/WinMe */)
|
|
|
|
{
|
|
|
|
skip("Level %d not supported\n", level);
|
|
|
|
continue;
|
|
|
|
}
|
2009-12-01 00:04:19 +01:00
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %d\n", GetLastError());
|
|
|
|
ok(needed > 0,"not expected needed buffer size %d\n", needed);
|
|
|
|
|
|
|
|
/* GetPrinterA returns the same number of bytes as GetPrinterW */
|
2020-04-13 09:52:54 +02:00
|
|
|
if (!ret && pGetPrinterW && level != 6 && level != 7)
|
2009-12-01 00:04:19 +01:00
|
|
|
{
|
|
|
|
DWORD double_needed;
|
|
|
|
ret = pGetPrinterW(hprn, level, NULL, 0, &double_needed);
|
2011-02-05 08:08:04 +01:00
|
|
|
ok(!ret, "level %d: GetPrinter error %d\n", level, GetLastError());
|
2009-12-01 00:04:19 +01:00
|
|
|
ok(double_needed == needed, "level %d: GetPrinterA returned different size %d than GetPrinterW (%d)\n", level, needed, double_needed);
|
|
|
|
}
|
|
|
|
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
filled = -1;
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetPrinterA(hprn, level, buf, needed, &filled);
|
2011-02-05 08:08:04 +01:00
|
|
|
ok(ret, "level %d: GetPrinter error %d\n", level, GetLastError());
|
2009-12-01 00:04:50 +01:00
|
|
|
ok(needed == filled, "needed %d != filled %d\n", needed, filled);
|
2009-12-01 00:04:19 +01:00
|
|
|
|
|
|
|
if (level == 2)
|
|
|
|
{
|
2013-10-24 23:06:43 +02:00
|
|
|
PRINTER_INFO_2A *pi_2 = (PRINTER_INFO_2A *)buf;
|
2009-12-01 00:04:19 +01:00
|
|
|
|
|
|
|
ok(pi_2->pPrinterName!= NULL, "not expected NULL ptr\n");
|
|
|
|
ok(pi_2->pDriverName!= NULL, "not expected NULL ptr\n");
|
|
|
|
|
|
|
|
trace("pPrinterName %s\n", pi_2->pPrinterName);
|
|
|
|
trace("pDriverName %s\n", pi_2->pDriverName);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = ClosePrinter(hprn);
|
|
|
|
ok(ret, "ClosePrinter error %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
2010-06-15 17:25:17 +02:00
|
|
|
static void test_GetPrinterData(void)
|
|
|
|
{
|
|
|
|
HANDLE hprn = 0;
|
|
|
|
DWORD res;
|
|
|
|
DWORD type;
|
|
|
|
CHAR buffer[MAX_PATH + 1];
|
|
|
|
DWORD needed;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
/* ToDo: test parameter validation, test with the default printer */
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(NULL, &hprn, NULL);
|
2010-06-15 17:25:17 +02:00
|
|
|
if (!res)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
buffer[MAX_PATH] = 0;
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
needed = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrinterDataA(hprn, defaultspooldirectory, &type, (LPBYTE) buffer, sizeof(buffer), &needed);
|
|
|
|
|
|
|
|
len = lstrlenA(buffer) + sizeof(CHAR);
|
|
|
|
/* NT4 and w2k require a buffer to save the UNICODE result also for the ANSI function */
|
|
|
|
ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
|
2010-11-17 15:08:18 +01:00
|
|
|
"got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d)\n",
|
|
|
|
res, type, needed, buffer, len);
|
2010-06-16 00:42:23 +02:00
|
|
|
|
|
|
|
needed = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = GetPrinterDataA(hprn, defaultspooldirectory, NULL, NULL, 0, &needed);
|
|
|
|
ok( (res == ERROR_MORE_DATA) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
|
2010-11-17 15:08:18 +01:00
|
|
|
"got %d, needed: %d (expected ERROR_MORE_DATA and %d)\n", res, needed, len);
|
2010-06-16 00:42:23 +02:00
|
|
|
|
2010-06-15 17:25:17 +02:00
|
|
|
/* ToDo: test SPLREG_* */
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ClosePrinter(hprn);
|
|
|
|
ok(res, "ClosePrinter error %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
|
|
|
static void test_GetPrinterDataEx(void)
|
|
|
|
{
|
|
|
|
HANDLE hprn = 0;
|
|
|
|
DWORD res;
|
|
|
|
DWORD type;
|
|
|
|
CHAR buffer[MAX_PATH + 1];
|
|
|
|
DWORD needed;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
/* not present before w2k */
|
|
|
|
if (!pGetPrinterDataExA) {
|
|
|
|
win_skip("GetPrinterDataEx not found\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ToDo: test parameter validation, test with the default printer */
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2013-10-24 23:06:43 +02:00
|
|
|
res = OpenPrinterA(NULL, &hprn, NULL);
|
2010-06-15 17:25:17 +02:00
|
|
|
if (!res)
|
|
|
|
{
|
|
|
|
win_skip("Unable to open the printserver: %d\n", GetLastError());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* keyname is ignored, when hprn is a HANDLE for a printserver */
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
buffer[MAX_PATH] = 0;
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
needed = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pGetPrinterDataExA(hprn, NULL, defaultspooldirectory, &type,
|
|
|
|
(LPBYTE) buffer, sizeof(buffer), &needed);
|
|
|
|
|
|
|
|
len = lstrlenA(buffer) + sizeof(CHAR);
|
|
|
|
/* NT4 and w2k require a buffer to save the UNICODE result also for the ANSI function */
|
|
|
|
ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
|
2010-11-17 15:08:18 +01:00
|
|
|
"got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d)\n",
|
|
|
|
res, type, needed, buffer, len);
|
2010-06-15 17:25:17 +02:00
|
|
|
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
buffer[MAX_PATH] = 0;
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
needed = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pGetPrinterDataExA(hprn, "", defaultspooldirectory, &type,
|
|
|
|
(LPBYTE) buffer, sizeof(buffer), &needed);
|
|
|
|
len = lstrlenA(buffer) + sizeof(CHAR);
|
|
|
|
ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
|
2010-11-17 15:08:18 +01:00
|
|
|
"got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d)\n",
|
|
|
|
res, type, needed, buffer, len);
|
2010-06-15 17:25:17 +02:00
|
|
|
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
buffer[MAX_PATH] = 0;
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
needed = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
/* Wine uses GetPrinterDataEx with "PrinterDriverData" to implement GetPrinterData */
|
|
|
|
res = pGetPrinterDataExA(hprn, "PrinterDriverData", defaultspooldirectory,
|
|
|
|
&type, (LPBYTE) buffer, sizeof(buffer), &needed);
|
|
|
|
len = lstrlenA(buffer) + sizeof(CHAR);
|
|
|
|
ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
|
2010-11-17 15:08:18 +01:00
|
|
|
"got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d)\n",
|
|
|
|
res, type, needed, buffer, len);
|
2010-06-15 17:25:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
memset(buffer, '#', sizeof(buffer));
|
|
|
|
buffer[MAX_PATH] = 0;
|
|
|
|
type = 0xdeadbeef;
|
|
|
|
needed = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = pGetPrinterDataExA(hprn, does_not_exist, defaultspooldirectory, &type,
|
|
|
|
(LPBYTE) buffer, sizeof(buffer), &needed);
|
|
|
|
len = lstrlenA(buffer) + sizeof(CHAR);
|
|
|
|
ok( !res && (type == REG_SZ) && ((needed == len) || (needed == (len * sizeof(WCHAR)))),
|
2010-11-17 15:08:18 +01:00
|
|
|
"got %d, type %d, needed: %d and '%s' (expected ERROR_SUCCESS, REG_SZ and %d)\n",
|
|
|
|
res, type, needed, buffer, len);
|
2010-06-15 17:25:17 +02:00
|
|
|
|
2010-06-16 00:42:23 +02:00
|
|
|
needed = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2010-06-17 00:38:24 +02:00
|
|
|
/* vista and w2k8 have a bug in GetPrinterDataEx:
|
|
|
|
the current LastError value is returned as result */
|
2010-06-16 00:42:23 +02:00
|
|
|
res = pGetPrinterDataExA(hprn, NULL, defaultspooldirectory, NULL, NULL, 0, &needed);
|
2010-06-17 00:38:24 +02:00
|
|
|
ok( ((res == ERROR_MORE_DATA) || broken(res == 0xdeadbeef)) &&
|
|
|
|
((needed == len) || (needed == (len * sizeof(WCHAR)))),
|
2010-11-17 15:08:18 +01:00
|
|
|
"got %d, needed: %d (expected ERROR_MORE_DATA and %d)\n", res, needed, len);
|
2010-06-17 00:38:24 +02:00
|
|
|
|
|
|
|
needed = 0xdeadbeef;
|
|
|
|
SetLastError(0xdeaddead);
|
|
|
|
res = pGetPrinterDataExA(hprn, NULL, defaultspooldirectory, NULL, NULL, 0, &needed);
|
|
|
|
ok( ((res == ERROR_MORE_DATA) || broken(res == 0xdeaddead)) &&
|
|
|
|
((needed == len) || (needed == (len * sizeof(WCHAR)))),
|
2010-11-17 15:08:18 +01:00
|
|
|
"got %d, needed: %d (expected ERROR_MORE_DATA and %d)\n", res, needed, len);
|
2010-06-16 00:42:23 +02:00
|
|
|
|
2010-06-15 17:25:17 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
res = ClosePrinter(hprn);
|
|
|
|
ok(res, "ClosePrinter error %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
2006-04-14 15:34:57 +02:00
|
|
|
static void test_GetPrinterDriver(void)
|
|
|
|
{
|
|
|
|
HANDLE hprn;
|
|
|
|
BOOL ret;
|
|
|
|
BYTE *buf;
|
|
|
|
INT level;
|
|
|
|
DWORD needed, filled;
|
|
|
|
|
|
|
|
if (!default_printer)
|
|
|
|
{
|
2007-03-05 21:44:18 +01:00
|
|
|
skip("There is no default printer installed\n");
|
2006-04-14 15:34:57 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hprn = 0;
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = OpenPrinterA(default_printer, &hprn, NULL);
|
2006-04-14 15:34:57 +02:00
|
|
|
if (!ret)
|
|
|
|
{
|
2007-03-05 21:44:18 +01:00
|
|
|
skip("Unable to open the default printer (%s)\n", default_printer);
|
2006-04-14 15:34:57 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(hprn != 0, "wrong hprn %p\n", hprn);
|
|
|
|
|
|
|
|
for (level = -1; level <= 7; level++)
|
|
|
|
{
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
needed = (DWORD)-1;
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetPrinterDriverA(hprn, NULL, level, NULL, 0, &needed);
|
2006-04-14 15:34:57 +02:00
|
|
|
ok(!ret, "level %d: GetPrinterDriver should fail\n", level);
|
|
|
|
if (level >= 1 && level <= 6)
|
|
|
|
{
|
2006-05-02 05:58:36 +02:00
|
|
|
/* Not all levels are supported on all Windows-Versions */
|
|
|
|
if(GetLastError() == ERROR_INVALID_LEVEL) continue;
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %d\n", GetLastError());
|
|
|
|
ok(needed > 0,"not expected needed buffer size %d\n", needed);
|
2006-04-14 15:34:57 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-02 05:58:36 +02:00
|
|
|
/* ERROR_OUTOFMEMORY found on win9x */
|
|
|
|
ok( ((GetLastError() == ERROR_INVALID_LEVEL) ||
|
|
|
|
(GetLastError() == ERROR_OUTOFMEMORY)),
|
2006-12-27 00:19:17 +01:00
|
|
|
"%d: returned %d with %d (expected '0' with: "
|
2006-05-02 05:58:36 +02:00
|
|
|
"ERROR_INVALID_LEVEL or ERROR_OUTOFMEMORY)\n",
|
|
|
|
level, ret, GetLastError());
|
|
|
|
/* needed is modified in win9x. The modified Value depends on the
|
|
|
|
default Printer. testing for "needed == (DWORD)-1" will fail */
|
2006-04-14 15:34:57 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-11-24 14:31:21 +01:00
|
|
|
/* GetPrinterDriverA returns the same number of bytes as GetPrinterDriverW */
|
2020-04-13 09:52:54 +02:00
|
|
|
if (!ret && pGetPrinterDriverW)
|
2009-11-24 14:31:21 +01:00
|
|
|
{
|
|
|
|
DWORD double_needed;
|
|
|
|
ret = pGetPrinterDriverW(hprn, NULL, level, NULL, 0, &double_needed);
|
2011-02-05 08:08:04 +01:00
|
|
|
ok(!ret, "level %d: GetPrinterDriver error %d\n", level, GetLastError());
|
2009-11-24 14:31:21 +01:00
|
|
|
ok(double_needed == needed, "GetPrinterDriverA returned different size %d than GetPrinterDriverW (%d)\n", needed, double_needed);
|
|
|
|
}
|
|
|
|
|
2006-04-14 15:34:57 +02:00
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
filled = -1;
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetPrinterDriverA(hprn, NULL, level, buf, needed, &filled);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(ret, "level %d: GetPrinterDriver error %d\n", level, GetLastError());
|
|
|
|
ok(needed == filled, "needed %d != filled %d\n", needed, filled);
|
2006-04-14 15:34:57 +02:00
|
|
|
|
|
|
|
if (level == 2)
|
|
|
|
{
|
2013-10-24 23:06:43 +02:00
|
|
|
DRIVER_INFO_2A *di_2 = (DRIVER_INFO_2A *)buf;
|
2006-04-14 15:34:57 +02:00
|
|
|
DWORD calculated = sizeof(*di_2);
|
2009-12-16 03:33:45 +01:00
|
|
|
HANDLE hf;
|
2006-04-14 15:34:57 +02:00
|
|
|
|
2006-05-02 05:58:36 +02:00
|
|
|
/* MSDN is wrong: The Drivers on the win9x-CD's have cVersion=0x0400
|
2012-07-29 16:34:46 +02:00
|
|
|
NT351: 1, NT4.0+w2k(Kernelmode): 2, w2k-win7(Usermode): 3, win8 and above(Usermode): 4 */
|
|
|
|
ok( (di_2->cVersion <= 4) ||
|
2006-10-13 13:20:32 +02:00
|
|
|
(di_2->cVersion == 0x0400), "di_2->cVersion = %d\n", di_2->cVersion);
|
2006-04-14 15:34:57 +02:00
|
|
|
ok(di_2->pName != NULL, "not expected NULL ptr\n");
|
|
|
|
ok(di_2->pEnvironment != NULL, "not expected NULL ptr\n");
|
|
|
|
ok(di_2->pDriverPath != NULL, "not expected NULL ptr\n");
|
|
|
|
ok(di_2->pDataFile != NULL, "not expected NULL ptr\n");
|
|
|
|
ok(di_2->pConfigFile != NULL, "not expected NULL ptr\n");
|
|
|
|
|
2006-10-13 13:20:32 +02:00
|
|
|
trace("cVersion %d\n", di_2->cVersion);
|
2006-04-14 15:34:57 +02:00
|
|
|
trace("pName %s\n", di_2->pName);
|
|
|
|
calculated += strlen(di_2->pName) + 1;
|
|
|
|
trace("pEnvironment %s\n", di_2->pEnvironment);
|
|
|
|
calculated += strlen(di_2->pEnvironment) + 1;
|
|
|
|
trace("pDriverPath %s\n", di_2->pDriverPath);
|
|
|
|
calculated += strlen(di_2->pDriverPath) + 1;
|
|
|
|
trace("pDataFile %s\n", di_2->pDataFile);
|
|
|
|
calculated += strlen(di_2->pDataFile) + 1;
|
|
|
|
trace("pConfigFile %s\n", di_2->pConfigFile);
|
|
|
|
calculated += strlen(di_2->pConfigFile) + 1;
|
|
|
|
|
2010-02-16 16:05:17 +01:00
|
|
|
hf = CreateFileA(di_2->pDriverPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
2009-12-16 03:33:45 +01:00
|
|
|
if(hf != INVALID_HANDLE_VALUE)
|
|
|
|
CloseHandle(hf);
|
|
|
|
ok(hf != INVALID_HANDLE_VALUE, "Could not open %s\n", di_2->pDriverPath);
|
|
|
|
|
2010-02-16 16:05:17 +01:00
|
|
|
hf = CreateFileA(di_2->pDataFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
2009-12-16 03:33:45 +01:00
|
|
|
if(hf != INVALID_HANDLE_VALUE)
|
|
|
|
CloseHandle(hf);
|
|
|
|
ok(hf != INVALID_HANDLE_VALUE, "Could not open %s\n", di_2->pDataFile);
|
|
|
|
|
2010-02-16 16:05:17 +01:00
|
|
|
hf = CreateFileA(di_2->pConfigFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
2009-12-16 03:33:45 +01:00
|
|
|
if(hf != INVALID_HANDLE_VALUE)
|
|
|
|
CloseHandle(hf);
|
|
|
|
ok(hf != INVALID_HANDLE_VALUE, "Could not open %s\n", di_2->pConfigFile);
|
|
|
|
|
2006-04-14 15:34:57 +02:00
|
|
|
/* XP allocates memory for both ANSI and unicode names */
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(filled >= calculated,"calculated %d != filled %d\n", calculated, filled);
|
2009-12-23 18:21:32 +01:00
|
|
|
|
|
|
|
/* Obscure test - demonstrate that Windows zero fills the buffer, even on failure */
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetPrinterDriverA(hprn, NULL, level, buf, needed - 2, &filled);
|
2011-06-15 17:01:07 +02:00
|
|
|
ok(!ret, "level %d: GetPrinterDriver succeeded with less buffer than it should\n", level);
|
|
|
|
ok(di_2->pDataFile == NULL ||
|
|
|
|
broken(di_2->pDataFile != NULL), /* Win9x/WinMe */
|
|
|
|
"Even on failure, GetPrinterDriver clears the buffer to zeros\n");
|
2006-04-14 15:34:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = ClosePrinter(hprn);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(ret, "ClosePrinter error %d\n", GetLastError());
|
2006-04-14 15:34:57 +02:00
|
|
|
}
|
2006-02-20 11:51:10 +01:00
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
static void test_DEVMODEA(const DEVMODEA *dm, LONG dmSize, LPCSTR exp_prn_name)
|
2006-04-18 12:36:58 +02:00
|
|
|
{
|
2013-10-24 23:06:43 +02:00
|
|
|
/* On NT3.51, some fields in DEVMODEA are empty/zero
|
2006-05-02 00:03:51 +02:00
|
|
|
(dmDeviceName, dmSpecVersion, dmDriverVersion and dmDriverExtra)
|
|
|
|
We skip the Tests on this Platform */
|
|
|
|
if (dm->dmSpecVersion || dm->dmDriverVersion || dm->dmDriverExtra) {
|
2006-05-12 15:03:20 +02:00
|
|
|
/* The 0-terminated Printername can be larger (MAX_PATH) than CCHDEVICENAME */
|
2009-12-08 10:25:18 +01:00
|
|
|
ok(!strncmp(exp_prn_name, (LPCSTR)dm->dmDeviceName, CCHDEVICENAME -1) ||
|
|
|
|
!strncmp(exp_prn_name, (LPCSTR)dm->dmDeviceName, CCHDEVICENAME -2), /* XP+ */
|
2006-05-02 00:03:51 +02:00
|
|
|
"expected '%s', got '%s'\n", exp_prn_name, dm->dmDeviceName);
|
|
|
|
ok(dm->dmSize + dm->dmDriverExtra == dmSize,
|
2006-10-13 13:20:32 +02:00
|
|
|
"%u != %d\n", dm->dmSize + dm->dmDriverExtra, dmSize);
|
2006-05-02 00:03:51 +02:00
|
|
|
}
|
2006-10-13 13:20:32 +02:00
|
|
|
trace("dmFields %08x\n", dm->dmFields);
|
2006-04-18 12:36:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_DocumentProperties(void)
|
|
|
|
{
|
|
|
|
HANDLE hprn;
|
|
|
|
LONG dm_size, ret;
|
2013-10-24 23:06:43 +02:00
|
|
|
DEVMODEA *dm;
|
2013-04-05 09:41:29 +02:00
|
|
|
char empty_str[] = "";
|
2006-04-18 12:36:58 +02:00
|
|
|
|
|
|
|
if (!default_printer)
|
|
|
|
{
|
2007-03-05 21:44:18 +01:00
|
|
|
skip("There is no default printer installed\n");
|
2006-04-18 12:36:58 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hprn = 0;
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = OpenPrinterA(default_printer, &hprn, NULL);
|
2006-04-18 12:36:58 +02:00
|
|
|
if (!ret)
|
|
|
|
{
|
2007-03-05 21:44:18 +01:00
|
|
|
skip("Unable to open the default printer (%s)\n", default_printer);
|
2006-04-18 12:36:58 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(hprn != 0, "wrong hprn %p\n", hprn);
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
dm_size = DocumentPropertiesA(0, hprn, NULL, NULL, NULL, 0);
|
|
|
|
trace("DEVMODEA required size %d\n", dm_size);
|
|
|
|
ok(dm_size >= sizeof(DEVMODEA), "unexpected DocumentPropertiesA ret value %d\n", dm_size);
|
2006-04-18 12:36:58 +02:00
|
|
|
|
|
|
|
dm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dm_size);
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = DocumentPropertiesA(0, hprn, NULL, dm, dm, DM_OUT_BUFFER);
|
|
|
|
ok(ret == IDOK, "DocumentPropertiesA ret value %d != expected IDOK\n", ret);
|
2006-04-18 12:36:58 +02:00
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = DocumentPropertiesA(0, hprn, empty_str, dm, dm, DM_OUT_BUFFER);
|
|
|
|
ok(ret == IDOK, "DocumentPropertiesA ret value %d != expected IDOK\n", ret);
|
2013-04-05 09:41:29 +02:00
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
test_DEVMODEA(dm, dm_size, default_printer);
|
2006-04-18 12:36:58 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, dm);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = ClosePrinter(hprn);
|
2006-10-13 13:20:32 +02:00
|
|
|
ok(ret, "ClosePrinter error %d\n", GetLastError());
|
2006-04-18 12:36:58 +02:00
|
|
|
}
|
|
|
|
|
2006-12-04 15:32:36 +01:00
|
|
|
static void test_EnumPrinters(void)
|
|
|
|
{
|
|
|
|
DWORD neededA, neededW, num;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-12-12 10:22:49 +01:00
|
|
|
neededA = -1;
|
2006-12-04 15:32:36 +01:00
|
|
|
ret = EnumPrintersA(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &neededA, &num);
|
2013-02-11 09:47:35 +01:00
|
|
|
if (is_spooler_deactivated(ret, GetLastError())) return;
|
2006-12-12 10:22:49 +01:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
/* We have 1 or more printers */
|
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "gle %d\n", GetLastError());
|
|
|
|
ok(neededA > 0, "Expected neededA to show the number of needed bytes\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We don't have any printers defined */
|
|
|
|
ok(GetLastError() == S_OK, "gle %d\n", GetLastError());
|
|
|
|
ok(neededA == 0, "Expected neededA to be zero\n");
|
|
|
|
}
|
2006-12-04 15:32:36 +01:00
|
|
|
ok(num == 0, "num %d\n", num);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-12-12 10:22:49 +01:00
|
|
|
neededW = -1;
|
2006-12-10 11:01:30 +01:00
|
|
|
ret = EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &neededW, &num);
|
2006-12-30 18:13:08 +01:00
|
|
|
/* EnumPrintersW is not supported on all platforms */
|
|
|
|
if (!ret && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
|
|
|
|
{
|
2009-02-25 10:30:13 +01:00
|
|
|
win_skip("EnumPrintersW is not implemented\n");
|
2006-12-30 18:13:08 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-12-12 10:22:49 +01:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
/* We have 1 or more printers */
|
|
|
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "gle %d\n", GetLastError());
|
|
|
|
ok(neededW > 0, "Expected neededW to show the number of needed bytes\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We don't have any printers defined */
|
|
|
|
ok(GetLastError() == S_OK, "gle %d\n", GetLastError());
|
|
|
|
ok(neededW == 0, "Expected neededW to be zero\n");
|
|
|
|
}
|
2006-12-04 15:32:36 +01:00
|
|
|
ok(num == 0, "num %d\n", num);
|
|
|
|
|
|
|
|
/* Outlook2003 relies on the buffer size returned by EnumPrintersA being big enough
|
|
|
|
to hold the buffer returned by EnumPrintersW */
|
|
|
|
ok(neededA == neededW, "neededA %d neededW %d\n", neededA, neededW);
|
|
|
|
}
|
|
|
|
|
2007-04-07 10:28:10 +02:00
|
|
|
static void test_DeviceCapabilities(void)
|
|
|
|
{
|
|
|
|
HANDLE hComdlg32;
|
|
|
|
BOOL (WINAPI *pPrintDlgA)(PRINTDLGA *);
|
|
|
|
PRINTDLGA prn_dlg;
|
2013-10-24 23:06:43 +02:00
|
|
|
DEVMODEA *dm;
|
2007-04-07 10:28:10 +02:00
|
|
|
DEVNAMES *dn;
|
|
|
|
const char *driver, *device, *port;
|
|
|
|
WORD *papers;
|
|
|
|
POINT *paper_size;
|
|
|
|
POINTS ext;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char name[64];
|
|
|
|
} *paper_name;
|
|
|
|
INT n_papers, n_paper_size, n_paper_names, n_copies, ret;
|
|
|
|
DWORD fields;
|
|
|
|
|
2013-10-01 23:09:53 +02:00
|
|
|
hComdlg32 = LoadLibraryA("comdlg32.dll");
|
2007-04-07 10:28:10 +02:00
|
|
|
assert(hComdlg32);
|
2007-05-24 16:41:17 +02:00
|
|
|
pPrintDlgA = (void *)GetProcAddress(hComdlg32, "PrintDlgA");
|
2007-04-07 10:28:10 +02:00
|
|
|
assert(pPrintDlgA);
|
|
|
|
|
|
|
|
memset(&prn_dlg, 0, sizeof(prn_dlg));
|
|
|
|
prn_dlg.lStructSize = sizeof(prn_dlg);
|
|
|
|
prn_dlg.Flags = PD_RETURNDEFAULT;
|
|
|
|
ret = pPrintDlgA(&prn_dlg);
|
|
|
|
FreeLibrary(hComdlg32);
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
skip("PrintDlg returned no default printer\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(prn_dlg.hDevMode != 0, "PrintDlg returned hDevMode == NULL\n");
|
|
|
|
ok(prn_dlg.hDevNames != 0, "PrintDlg returned hDevNames == NULL\n");
|
|
|
|
|
|
|
|
dm = GlobalLock(prn_dlg.hDevMode);
|
|
|
|
ok(dm != NULL, "GlobalLock(prn_dlg.hDevMode) failed\n");
|
|
|
|
trace("dmDeviceName \"%s\"\n", dm->dmDeviceName);
|
|
|
|
|
|
|
|
dn = GlobalLock(prn_dlg.hDevNames);
|
|
|
|
ok(dn != NULL, "GlobalLock(prn_dlg.hDevNames) failed\n");
|
|
|
|
ok(dn->wDriverOffset, "expected not 0 wDriverOffset\n");
|
|
|
|
ok(dn->wDeviceOffset, "expected not 0 wDeviceOffset\n");
|
|
|
|
ok(dn->wOutputOffset, "expected not 0 wOutputOffset\n");
|
|
|
|
ok(dn->wDefault == DN_DEFAULTPRN, "expected DN_DEFAULTPRN got %x\n", dn->wDefault);
|
|
|
|
driver = (const char *)dn + dn->wDriverOffset;
|
|
|
|
device = (const char *)dn + dn->wDeviceOffset;
|
|
|
|
port = (const char *)dn + dn->wOutputOffset;
|
|
|
|
trace("driver \"%s\" device \"%s\" port \"%s\"\n", driver, device, port);
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
test_DEVMODEA(dm, dm->dmSize + dm->dmDriverExtra, device);
|
2007-04-07 10:28:10 +02:00
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
n_papers = DeviceCapabilitiesA(device, port, DC_PAPERS, NULL, NULL);
|
|
|
|
ok(n_papers > 0, "DeviceCapabilitiesA DC_PAPERS failed\n");
|
2007-04-07 10:28:10 +02:00
|
|
|
papers = HeapAlloc(GetProcessHeap(), 0, sizeof(*papers) * n_papers);
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = DeviceCapabilitiesA(device, port, DC_PAPERS, (LPSTR)papers, NULL);
|
2007-04-07 10:28:10 +02:00
|
|
|
ok(ret == n_papers, "expected %d, got %d\n", n_papers, ret);
|
2009-11-26 00:55:00 +01:00
|
|
|
#ifdef VERBOSE
|
2007-04-07 10:28:10 +02:00
|
|
|
for (ret = 0; ret < n_papers; ret++)
|
|
|
|
trace("papers[%d] = %d\n", ret, papers[ret]);
|
|
|
|
#endif
|
|
|
|
HeapFree(GetProcessHeap(), 0, papers);
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
n_paper_size = DeviceCapabilitiesA(device, port, DC_PAPERSIZE, NULL, NULL);
|
|
|
|
ok(n_paper_size > 0, "DeviceCapabilitiesA DC_PAPERSIZE failed\n");
|
2007-04-07 10:28:10 +02:00
|
|
|
ok(n_paper_size == n_papers, "n_paper_size %d != n_papers %d\n", n_paper_size, n_papers);
|
|
|
|
paper_size = HeapAlloc(GetProcessHeap(), 0, sizeof(*paper_size) * n_paper_size);
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = DeviceCapabilitiesA(device, port, DC_PAPERSIZE, (LPSTR)paper_size, NULL);
|
2007-04-07 10:28:10 +02:00
|
|
|
ok(ret == n_paper_size, "expected %d, got %d\n", n_paper_size, ret);
|
2009-11-26 00:55:00 +01:00
|
|
|
#ifdef VERBOSE
|
2007-04-07 10:28:10 +02:00
|
|
|
for (ret = 0; ret < n_paper_size; ret++)
|
|
|
|
trace("paper_size[%d] = %d x %d\n", ret, paper_size[ret].x, paper_size[ret].y);
|
|
|
|
#endif
|
|
|
|
HeapFree(GetProcessHeap(), 0, paper_size);
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
n_paper_names = DeviceCapabilitiesA(device, port, DC_PAPERNAMES, NULL, NULL);
|
|
|
|
ok(n_paper_names > 0, "DeviceCapabilitiesA DC_PAPERNAMES failed\n");
|
2007-04-07 10:28:10 +02:00
|
|
|
ok(n_paper_names == n_papers, "n_paper_names %d != n_papers %d\n", n_paper_names, n_papers);
|
|
|
|
paper_name = HeapAlloc(GetProcessHeap(), 0, sizeof(*paper_name) * n_paper_names);
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = DeviceCapabilitiesA(device, port, DC_PAPERNAMES, (LPSTR)paper_name, NULL);
|
2007-04-07 10:28:10 +02:00
|
|
|
ok(ret == n_paper_names, "expected %d, got %d\n", n_paper_names, ret);
|
2009-11-26 00:55:00 +01:00
|
|
|
#ifdef VERBOSE
|
2007-04-07 10:28:10 +02:00
|
|
|
for (ret = 0; ret < n_paper_names; ret++)
|
|
|
|
trace("paper_name[%u] = %s\n", ret, paper_name[ret].name);
|
|
|
|
#endif
|
|
|
|
HeapFree(GetProcessHeap(), 0, paper_name);
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
n_copies = DeviceCapabilitiesA(device, port, DC_COPIES, NULL, dm);
|
|
|
|
ok(n_copies > 0, "DeviceCapabilitiesA DC_COPIES failed\n");
|
2007-04-07 10:28:10 +02:00
|
|
|
trace("n_copies = %d\n", n_copies);
|
|
|
|
|
2012-06-24 19:40:56 +02:00
|
|
|
/* these capabilities are not available on all printer drivers */
|
2008-04-25 08:10:02 +02:00
|
|
|
if (0)
|
|
|
|
{
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = DeviceCapabilitiesA(device, port, DC_MAXEXTENT, NULL, NULL);
|
|
|
|
ok(ret != -1, "DeviceCapabilitiesA DC_MAXEXTENT failed\n");
|
2008-04-25 08:10:02 +02:00
|
|
|
ext = MAKEPOINTS(ret);
|
|
|
|
trace("max ext = %d x %d\n", ext.x, ext.y);
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = DeviceCapabilitiesA(device, port, DC_MINEXTENT, NULL, NULL);
|
|
|
|
ok(ret != -1, "DeviceCapabilitiesA DC_MINEXTENT failed\n");
|
2008-04-25 08:10:02 +02:00
|
|
|
ext = MAKEPOINTS(ret);
|
|
|
|
trace("min ext = %d x %d\n", ext.x, ext.y);
|
|
|
|
}
|
2007-04-07 10:28:10 +02:00
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
fields = DeviceCapabilitiesA(device, port, DC_FIELDS, NULL, NULL);
|
|
|
|
ok(fields != (DWORD)-1, "DeviceCapabilitiesA DC_FIELDS failed\n");
|
2010-02-16 15:59:38 +01:00
|
|
|
ok(fields == (dm->dmFields | DM_FORMNAME) ||
|
2011-10-31 20:00:26 +01:00
|
|
|
fields == ((dm->dmFields | DM_FORMNAME | DM_PAPERSIZE) & ~(DM_PAPERLENGTH|DM_PAPERWIDTH)) ||
|
2010-02-16 15:59:38 +01:00
|
|
|
broken(fields == dm->dmFields), /* Win9x/WinMe */
|
2011-10-31 20:00:26 +01:00
|
|
|
"fields %x, dm->dmFields %x\n", fields, dm->dmFields);
|
2007-04-07 10:28:10 +02:00
|
|
|
|
|
|
|
GlobalUnlock(prn_dlg.hDevMode);
|
|
|
|
GlobalFree(prn_dlg.hDevMode);
|
|
|
|
GlobalUnlock(prn_dlg.hDevNames);
|
|
|
|
GlobalFree(prn_dlg.hDevNames);
|
|
|
|
}
|
|
|
|
|
2012-04-03 12:43:40 +02:00
|
|
|
static void test_OpenPrinter_defaults(void)
|
|
|
|
{
|
|
|
|
HANDLE printer;
|
|
|
|
BOOL ret;
|
|
|
|
DWORD needed;
|
|
|
|
short default_size;
|
2013-10-24 23:06:43 +02:00
|
|
|
ADDJOB_INFO_1A *add_job;
|
|
|
|
JOB_INFO_2A *job_info;
|
|
|
|
DEVMODEA my_dm;
|
|
|
|
PRINTER_DEFAULTSA prn_def;
|
|
|
|
PRINTER_INFO_2A *pi;
|
2012-04-03 12:43:40 +02:00
|
|
|
|
|
|
|
if (!default_printer)
|
|
|
|
{
|
|
|
|
skip("There is no default printer installed\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Printer opened with NULL defaults. Retrieve default paper size
|
|
|
|
and confirm that jobs have this size. */
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = OpenPrinterA( default_printer, &printer, NULL );
|
2012-04-03 12:43:40 +02:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
skip("Unable to open the default printer (%s)\n", default_printer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetPrinterA( printer, 2, NULL, 0, &needed );
|
2012-04-03 12:43:40 +02:00
|
|
|
ok( !ret, "got %d\n", ret );
|
|
|
|
pi = HeapAlloc( GetProcessHeap(), 0, needed );
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetPrinterA( printer, 2, (BYTE *)pi, needed, &needed );
|
2013-10-27 11:47:33 +01:00
|
|
|
ok( ret, "GetPrinterA() failed le=%d\n", GetLastError() );
|
2012-04-03 12:43:40 +02:00
|
|
|
default_size = pi->pDevMode->u1.s1.dmPaperSize;
|
|
|
|
HeapFree( GetProcessHeap(), 0, pi );
|
|
|
|
|
2013-10-31 03:52:25 +01:00
|
|
|
needed = 0;
|
|
|
|
SetLastError( 0xdeadbeef );
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = AddJobA( printer, 1, NULL, 0, &needed );
|
2012-04-03 12:43:40 +02:00
|
|
|
ok( !ret, "got %d\n", ret );
|
2013-10-31 03:52:25 +01:00
|
|
|
if (GetLastError() == ERROR_NOT_SUPPORTED) /* win8 */
|
|
|
|
{
|
|
|
|
win_skip( "AddJob is not supported on this platform\n" );
|
|
|
|
ClosePrinter( printer );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError() );
|
|
|
|
ok( needed > sizeof(ADDJOB_INFO_1A), "AddJob needs %u bytes\n", needed);
|
|
|
|
add_job = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, needed );
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = AddJobA( printer, 1, (BYTE *)add_job, needed, &needed );
|
2013-10-27 11:47:33 +01:00
|
|
|
ok( ret, "AddJobA() failed le=%d\n", GetLastError() );
|
2012-04-03 12:43:40 +02:00
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetJobA( printer, add_job->JobId, 2, NULL, 0, &needed );
|
2012-04-03 12:43:40 +02:00
|
|
|
ok( !ret, "got %d\n", ret );
|
|
|
|
job_info = HeapAlloc( GetProcessHeap(), 0, needed );
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetJobA( printer, add_job->JobId, 2, (BYTE *)job_info, needed, &needed );
|
2013-10-27 11:47:33 +01:00
|
|
|
ok( ret, "GetJobA() failed le=%d\n", GetLastError() );
|
2012-04-03 12:43:40 +02:00
|
|
|
|
2020-04-13 09:52:54 +02:00
|
|
|
todo_wine
|
2013-10-24 23:06:43 +02:00
|
|
|
ok( job_info->pDevMode != NULL, "got NULL DEVMODEA\n");
|
2012-04-03 12:43:40 +02:00
|
|
|
if (job_info->pDevMode)
|
|
|
|
ok( job_info->pDevMode->u1.s1.dmPaperSize == default_size, "got %d default %d\n",
|
|
|
|
job_info->pDevMode->u1.s1.dmPaperSize, default_size );
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, job_info );
|
|
|
|
ScheduleJob( printer, add_job->JobId ); /* remove the empty job */
|
|
|
|
HeapFree( GetProcessHeap(), 0, add_job );
|
|
|
|
ClosePrinter( printer );
|
|
|
|
|
|
|
|
/* Printer opened with something other than the default paper size. */
|
|
|
|
|
|
|
|
memset( &my_dm, 0, sizeof(my_dm) );
|
|
|
|
my_dm.dmSize = sizeof(my_dm);
|
|
|
|
my_dm.dmFields = DM_PAPERSIZE;
|
|
|
|
my_dm.u1.s1.dmPaperSize = (default_size == DMPAPER_A4) ? DMPAPER_LETTER : DMPAPER_A4;
|
|
|
|
|
|
|
|
prn_def.pDatatype = NULL;
|
|
|
|
prn_def.pDevMode = &my_dm;
|
|
|
|
prn_def.DesiredAccess = PRINTER_ACCESS_USE;
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = OpenPrinterA( default_printer, &printer, &prn_def );
|
2013-10-27 11:47:33 +01:00
|
|
|
ok( ret, "OpenPrinterA() failed le=%d\n", GetLastError() );
|
2012-04-03 12:43:40 +02:00
|
|
|
|
|
|
|
/* GetPrinter stills returns default size */
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetPrinterA( printer, 2, NULL, 0, &needed );
|
2012-04-03 12:43:40 +02:00
|
|
|
ok( !ret, "got %d\n", ret );
|
|
|
|
pi = HeapAlloc( GetProcessHeap(), 0, needed );
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetPrinterA( printer, 2, (BYTE *)pi, needed, &needed );
|
2013-10-27 11:47:33 +01:00
|
|
|
ok( ret, "GetPrinterA() failed le=%d\n", GetLastError() );
|
2012-04-03 12:43:40 +02:00
|
|
|
ok( pi->pDevMode->u1.s1.dmPaperSize == default_size, "got %d default %d\n",
|
|
|
|
pi->pDevMode->u1.s1.dmPaperSize, default_size );
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, pi );
|
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
/* However the GetJobA has the new size */
|
|
|
|
ret = AddJobA( printer, 1, NULL, 0, &needed );
|
2012-04-03 12:43:40 +02:00
|
|
|
ok( !ret, "got %d\n", ret );
|
|
|
|
add_job = HeapAlloc( GetProcessHeap(), 0, needed );
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = AddJobA( printer, 1, (BYTE *)add_job, needed, &needed );
|
2013-10-27 11:47:33 +01:00
|
|
|
ok( ret, "AddJobA() failed le=%d\n", GetLastError() );
|
2012-04-03 12:43:40 +02:00
|
|
|
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetJobA( printer, add_job->JobId, 2, NULL, 0, &needed );
|
2012-04-03 12:43:40 +02:00
|
|
|
ok( !ret, "got %d\n", ret );
|
|
|
|
job_info = HeapAlloc( GetProcessHeap(), 0, needed );
|
2013-10-24 23:06:43 +02:00
|
|
|
ret = GetJobA( printer, add_job->JobId, 2, (BYTE *)job_info, needed, &needed );
|
2013-10-27 11:47:33 +01:00
|
|
|
ok( ret, "GetJobA() failed le=%d\n", GetLastError() );
|
2012-04-03 12:43:40 +02:00
|
|
|
|
|
|
|
ok( job_info->pDevMode->dmFields == DM_PAPERSIZE, "got %08x\n",
|
|
|
|
job_info->pDevMode->dmFields );
|
|
|
|
ok( job_info->pDevMode->u1.s1.dmPaperSize == my_dm.u1.s1.dmPaperSize,
|
|
|
|
"got %d new size %d\n",
|
|
|
|
job_info->pDevMode->u1.s1.dmPaperSize, my_dm.u1.s1.dmPaperSize );
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, job_info );
|
|
|
|
ScheduleJob( printer, add_job->JobId ); /* remove the empty job */
|
|
|
|
HeapFree( GetProcessHeap(), 0, add_job );
|
|
|
|
ClosePrinter( printer );
|
|
|
|
}
|
|
|
|
|
2019-10-07 04:59:41 +02:00
|
|
|
static void test_IsValidDevmodeW(void)
|
|
|
|
{
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
DWORD dmFields;
|
|
|
|
WORD dmSize;
|
|
|
|
BOOL ret;
|
|
|
|
} test[] =
|
|
|
|
{
|
|
|
|
{ 0, FIELD_OFFSET(DEVMODEW, dmFields) + 0, FALSE },
|
|
|
|
{ 0, FIELD_OFFSET(DEVMODEW, dmFields) + 1, FALSE },
|
|
|
|
{ 0, FIELD_OFFSET(DEVMODEW, dmFields) + 2, FALSE },
|
|
|
|
{ 0, FIELD_OFFSET(DEVMODEW, dmFields) + 3, FALSE },
|
|
|
|
{ 0, FIELD_OFFSET(DEVMODEW, dmFields) + 4, TRUE },
|
|
|
|
|
|
|
|
{ DM_ORIENTATION, FIELD_OFFSET(DEVMODEW, u1.s1.dmOrientation) + 0, FALSE },
|
|
|
|
{ DM_ORIENTATION, FIELD_OFFSET(DEVMODEW, u1.s1.dmOrientation) + 1, FALSE },
|
|
|
|
{ DM_ORIENTATION, FIELD_OFFSET(DEVMODEW, u1.s1.dmOrientation) + 2, TRUE },
|
|
|
|
|
|
|
|
{ DM_NUP, FIELD_OFFSET(DEVMODEW, u2.dmNup) + 0, FALSE },
|
|
|
|
{ DM_NUP, FIELD_OFFSET(DEVMODEW, u2.dmNup) + 1, FALSE },
|
|
|
|
{ DM_NUP, FIELD_OFFSET(DEVMODEW, u2.dmNup) + 2, FALSE },
|
|
|
|
{ DM_NUP, FIELD_OFFSET(DEVMODEW, u2.dmNup) + 3, FALSE },
|
|
|
|
{ DM_NUP, FIELD_OFFSET(DEVMODEW, u2.dmNup) + 4, TRUE },
|
|
|
|
|
|
|
|
};
|
|
|
|
DEVMODEW dm;
|
|
|
|
int i;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
ret = IsValidDevmodeW(NULL, 0);
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
ret = IsValidDevmodeW(NULL, sizeof(DEVMODEW));
|
|
|
|
ok(!ret, "got %d\n", ret);
|
|
|
|
|
|
|
|
memset(&dm, 0, sizeof(dm));
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(test); i++)
|
|
|
|
{
|
|
|
|
dm.dmSize = test[i].dmSize;
|
|
|
|
dm.dmFields = test[i].dmFields;
|
|
|
|
ret = IsValidDevmodeW(&dm, dm.dmSize);
|
|
|
|
ok(ret == test[i].ret, "%d: got %d\n", i, ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
START_TEST(info)
|
|
|
|
{
|
2013-10-01 23:09:53 +02:00
|
|
|
hwinspool = LoadLibraryA("winspool.drv");
|
2010-06-15 17:25:17 +02:00
|
|
|
pAddPortExA = (void *) GetProcAddress(hwinspool, "AddPortExA");
|
|
|
|
pEnumPrinterDriversW = (void *) GetProcAddress(hwinspool, "EnumPrinterDriversW");
|
2005-12-12 13:02:15 +01:00
|
|
|
pGetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterA");
|
2010-06-15 17:25:17 +02:00
|
|
|
pGetPrinterDataExA = (void *) GetProcAddress(hwinspool, "GetPrinterDataExA");
|
2009-11-24 14:31:21 +01:00
|
|
|
pGetPrinterDriverW = (void *) GetProcAddress(hwinspool, "GetPrinterDriverW");
|
2009-12-01 00:04:19 +01:00
|
|
|
pGetPrinterW = (void *) GetProcAddress(hwinspool, "GetPrinterW");
|
2010-06-15 17:25:17 +02:00
|
|
|
pSetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "SetDefaultPrinterA");
|
2007-02-02 00:46:03 +01:00
|
|
|
pXcvDataW = (void *) GetProcAddress(hwinspool, "XcvDataW");
|
2005-12-12 13:02:15 +01:00
|
|
|
|
2006-12-12 17:18:57 +01:00
|
|
|
find_default_printer();
|
2006-12-22 00:48:16 +01:00
|
|
|
find_local_server();
|
2007-02-02 16:04:46 +01:00
|
|
|
find_tempfile();
|
2005-12-12 13:02:15 +01:00
|
|
|
|
2006-04-10 00:29:22 +02:00
|
|
|
test_AddMonitor();
|
2006-11-28 00:50:57 +01:00
|
|
|
test_AddPort();
|
2007-06-18 00:58:49 +02:00
|
|
|
test_AddPortEx();
|
2006-11-07 00:07:48 +01:00
|
|
|
test_ConfigurePort();
|
2016-11-01 23:21:42 +01:00
|
|
|
test_ClosePrinter();
|
2006-04-16 02:42:34 +02:00
|
|
|
test_DeleteMonitor();
|
2006-11-28 00:48:04 +01:00
|
|
|
test_DeletePort();
|
2007-04-07 10:28:10 +02:00
|
|
|
test_DeviceCapabilities();
|
2006-04-18 12:36:58 +02:00
|
|
|
test_DocumentProperties();
|
2006-06-16 09:54:55 +02:00
|
|
|
test_EnumForms(NULL);
|
|
|
|
if (default_printer) test_EnumForms(default_printer);
|
2007-02-02 00:46:03 +01:00
|
|
|
test_EnumMonitors();
|
2006-11-04 00:28:08 +01:00
|
|
|
test_EnumPorts();
|
2007-08-10 10:47:36 +02:00
|
|
|
test_EnumPrinterDrivers();
|
2007-02-02 00:46:03 +01:00
|
|
|
test_EnumPrinters();
|
2009-10-14 23:50:49 +02:00
|
|
|
test_EnumPrintProcessors();
|
2006-02-01 12:32:10 +01:00
|
|
|
test_GetDefaultPrinter();
|
|
|
|
test_GetPrinterDriverDirectory();
|
2006-06-09 21:54:19 +02:00
|
|
|
test_GetPrintProcessorDirectory();
|
2016-11-01 23:21:42 +01:00
|
|
|
test_IsValidDevmodeW();
|
2006-02-01 12:32:10 +01:00
|
|
|
test_OpenPrinter();
|
2016-11-01 23:21:42 +01:00
|
|
|
test_OpenPrinter_defaults();
|
2009-12-01 00:04:19 +01:00
|
|
|
test_GetPrinter();
|
2010-06-15 17:25:17 +02:00
|
|
|
test_GetPrinterData();
|
|
|
|
test_GetPrinterDataEx();
|
2006-04-14 15:34:57 +02:00
|
|
|
test_GetPrinterDriver();
|
2006-02-20 11:51:10 +01:00
|
|
|
test_SetDefaultPrinter();
|
2007-02-02 00:46:03 +01:00
|
|
|
test_XcvDataW_MonitorUI();
|
2007-02-02 16:04:46 +01:00
|
|
|
test_XcvDataW_PortIsValid();
|
2007-03-06 18:40:26 +01:00
|
|
|
|
|
|
|
/* Cleanup our temporary file */
|
|
|
|
DeleteFileA(tempfileA);
|
2003-01-15 01:50:48 +01:00
|
|
|
}
|