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>
|
|
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
|
#include "wine/test.h"
|
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-02-02 16:04:46 +01: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"
|
|
|
|
|
|
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
|
|
|
|
|
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[] = "";
|
|
|
|
|
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";
|
2006-11-07 00:07:48 +01:00
|
|
|
|
static CHAR portname_com1[] = "COM1:";
|
|
|
|
|
static CHAR portname_file[] = "FILE:";
|
|
|
|
|
static CHAR portname_lpt1[] = "LPT1:";
|
2006-12-22 00:48:08 +01: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";
|
|
|
|
|
|
|
|
|
|
static WCHAR cmd_MonitorUIW[] = {'M','o','n','i','t','o','r','U','I',0};
|
2007-02-02 16:04:46 +01:00
|
|
|
|
static WCHAR cmd_PortIsValidW[] = {'P','o','r','t','I','s','V','a','l','i','d',0};
|
2007-02-02 00:46:03 +01:00
|
|
|
|
static WCHAR emptyW[] = {0};
|
|
|
|
|
|
2007-02-02 16:04:46 +01:00
|
|
|
|
static WCHAR portname_com1W[] = {'C','O','M','1',':',0};
|
|
|
|
|
static WCHAR portname_com2W[] = {'C','O','M','2',':',0};
|
|
|
|
|
static WCHAR portname_fileW[] = {'F','I','L','E',':',0};
|
|
|
|
|
static WCHAR portname_lpt1W[] = {'L','P','T','1',':',0};
|
|
|
|
|
static WCHAR portname_lpt2W[] = {'L','P','T','2',':',0};
|
2005-11-15 17:51:45 +01:00
|
|
|
|
|
2005-12-12 13:02:15 +01:00
|
|
|
|
static HANDLE hwinspool;
|
|
|
|
|
static FARPROC pGetDefaultPrinterA;
|
2006-02-20 11:51:10 +01:00
|
|
|
|
static FARPROC pSetDefaultPrinterA;
|
2007-02-02 00:46:03 +01:00
|
|
|
|
static DWORD (WINAPI * pXcvDataW)(HANDLE, LPCWSTR, PBYTE, DWORD, PBYTE, DWORD, PDWORD, PDWORD);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ################################ */
|
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
|
|
|
|
|
2007-02-02 16:04:46 +01:00
|
|
|
|
/* ################################ */
|
2006-02-02 13:50:36 +01:00
|
|
|
|
/* report common behavior only once */
|
|
|
|
|
static DWORD report_deactivated_spooler = 1;
|
|
|
|
|
#define RETURN_ON_DEACTIVATED_SPOOLER(res) \
|
|
|
|
|
if((res == 0) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE)) \
|
|
|
|
|
{ \
|
|
|
|
|
if(report_deactivated_spooler > 0) { \
|
|
|
|
|
report_deactivated_spooler--; \
|
|
|
|
|
trace("The Service 'Spooler' is required for many test\n"); \
|
|
|
|
|
} \
|
|
|
|
|
return; \
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
trace("default_printer: '%s'\n", default_printer);
|
|
|
|
|
}
|
|
|
|
|
if (default_printer == NULL)
|
|
|
|
|
{
|
|
|
|
|
HKEY hwindows;
|
|
|
|
|
DWORD type;
|
|
|
|
|
/* NT 3.x and above */
|
|
|
|
|
if (RegOpenKeyEx(HKEY_CURRENT_USER,
|
|
|
|
|
"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows",
|
|
|
|
|
0, KEY_QUERY_VALUE, &hwindows) == NO_ERROR) {
|
|
|
|
|
|
|
|
|
|
needed = sizeof(buffer);
|
|
|
|
|
if (RegQueryValueEx(hwindows, "device", NULL,
|
|
|
|
|
&type, (LPBYTE)buffer, &needed) == NO_ERROR) {
|
|
|
|
|
|
|
|
|
|
ptr = strchr(buffer, ',');
|
|
|
|
|
if (ptr) {
|
|
|
|
|
ptr[0] = '\0';
|
|
|
|
|
default_printer = buffer;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RegCloseKey(hwindows);
|
|
|
|
|
}
|
|
|
|
|
trace("default_printer: '%s'\n", default_printer);
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
trace("default_printer: '%s'\n", default_printer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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"},
|
|
|
|
|
{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;
|
|
|
|
|
|
|
|
|
|
num_tests = (sizeof(monitor_table)/sizeof(struct monitor_entry));
|
|
|
|
|
|
|
|
|
|
/* cleanup */
|
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());
|
|
|
|
|
|
2007-01-06 19:24:22 +01:00
|
|
|
|
if (0)
|
|
|
|
|
{
|
2006-05-22 00:39:33 +02:00
|
|
|
|
/* This test crash with 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());
|
2007-01-06 19:24:22 +01:00
|
|
|
|
}
|
2006-04-10 00:29:22 +02:00
|
|
|
|
|
|
|
|
|
ZeroMemory(&mi2a, sizeof(MONITOR_INFO_2A));
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
|
|
|
|
|
if (!res && (GetLastError() == ERROR_ACCESS_DENIED)) {
|
|
|
|
|
trace("skip tests (ACCESS_DENIED)\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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) {
|
|
|
|
|
trace("No usable Monitor found: Skip tests\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-06 19:24:22 +01:00
|
|
|
|
if (0)
|
|
|
|
|
{
|
2006-04-10 00:29:22 +02:00
|
|
|
|
/* The Test is deactivated, because when mi2a.pName is NULL, the subkey
|
|
|
|
|
HKLM\System\CurrentControlSet\Control\Print\Monitors\C:\WINDOWS\SYSTEM
|
|
|
|
|
or HKLM\System\CurrentControlSet\Control\Print\Monitors\<EFBFBD>
|
|
|
|
|
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);
|
|
|
|
|
/* 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);
|
2006-10-13 13:20:32 +02:00
|
|
|
|
ok(res, "returned %d with %d (expected '!= 0')\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);
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
/* 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 */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_ACCESS_DENIED)) {
|
|
|
|
|
trace("skip tests (ACCESS_DENIED)\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/* 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());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
|
2006-11-07 00:07:48 +01:00
|
|
|
|
static void test_ConfigurePort(void)
|
|
|
|
|
{
|
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = ConfigurePortA(NULL, 0, NULL);
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
/* 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 */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_ACCESS_DENIED)) {
|
|
|
|
|
trace(" skip tests (ACCESS_DENIED)\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/* 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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
|
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) {
|
|
|
|
|
trace("No usable Monitor found: Skip tests\n");
|
|
|
|
|
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);
|
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
|
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = DeletePortA(NULL, 0, empty);
|
|
|
|
|
/* Allowed only for (Printer-)Administrators */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_ACCESS_DENIED)) {
|
|
|
|
|
trace("skip tests (ACCESS_DENIED)\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = OpenPrinter(pName, &hprinter, NULL);
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
if (!res || !hprinter)
|
|
|
|
|
{
|
|
|
|
|
/* Open the local Prinserver is not supported on win9x */
|
|
|
|
|
if (pName) trace("Failed to open '%s', skiping the test\n", pName);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* EnumForms is not implemented in win9x */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
|
|
|
|
|
|
|
|
|
|
/* EnumForms for the Server not implemented on all NT-Versions */
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
/* use only a short test, when we test with an invalid level */
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
/* We can dump the returned Data here */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
|
|
|
|
|
/* not implemented yet in wine */
|
|
|
|
|
if (!res && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)) continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* use only a short test, when we test with an invalid level */
|
|
|
|
|
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)) {
|
2006-10-13 13:20:32 +02:00
|
|
|
|
trace("Level %d not supported, skipping tests\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) {
|
|
|
|
|
trace("no valid buffer size returned, skipping tests\n");
|
|
|
|
|
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);
|
|
|
|
|
ok( res || (!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);
|
|
|
|
|
ok( res || (!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);
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
|
|
|
|
|
/* use only a short test, when we test with an invalid level */
|
|
|
|
|
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)) {
|
|
|
|
|
trace("Level %d not supported, skipping tests\n", level);
|
|
|
|
|
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);
|
|
|
|
|
res = EnumPorts(NULL, level, buffer, cbBuf, NULL, &pcReturned);
|
|
|
|
|
/* 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);
|
|
|
|
|
res = EnumPorts(NULL, level, buffer, cbBuf, &pcbNeeded, NULL);
|
|
|
|
|
/* 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
|
|
|
|
|
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);
|
2004-06-14 18:54:42 +02:00
|
|
|
|
if (!retval || !exact || !strlen(buffer) ||
|
|
|
|
|
(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);
|
2006-10-13 13:20:32 +02:00
|
|
|
|
trace("first call returned 0x%04x, with %d: buffer size 0x%08x\n",
|
2006-02-02 13:50:36 +01:00
|
|
|
|
res, GetLastError(), cbBuf);
|
2003-01-15 01:50:48 +01:00
|
|
|
|
|
2006-02-02 13:50:36 +01:00
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
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) {
|
|
|
|
|
trace("no valid buffer size returned, skipping tests\n");
|
|
|
|
|
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);
|
2003-01-24 01:45:21 +01:00
|
|
|
|
ok( (!res && RPC_X_NULL_REF_POINTER == GetLastError()) || res,
|
|
|
|
|
"expected either result == 0 and "
|
|
|
|
|
"last error == RPC_X_NULL_REF_POINTER or result != 0 "
|
2006-10-13 13:20:32 +02:00
|
|
|
|
"got result %d and last error == %d\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);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
ok(res || (GetLastError() == RPC_X_NULL_REF_POINTER),
|
2006-12-27 00:19:17 +01:00
|
|
|
|
"returned %d with %d (expected '!=0' or '0' with "
|
2006-02-06 20:58:14 +01:00
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
|
2006-02-02 13:50:36 +01:00
|
|
|
|
|
|
|
|
|
|
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);
|
2006-12-14 17:59:46 +01:00
|
|
|
|
/* The deactivated Spooler is caught here on NT3.51 */
|
2006-06-09 21:54:19 +02:00
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
/* Buffer to small */
|
|
|
|
|
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);
|
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);
|
|
|
|
|
/* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
|
|
|
|
|
ok( res || (GetLastError() == RPC_X_NULL_REF_POINTER),
|
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
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA( NULL, NULL, 1, NULL, cbBuf, NULL);
|
|
|
|
|
/* NT: RPC_X_NULL_REF_POINTER, 9x: res != 0 */
|
|
|
|
|
ok( res || (GetLastError() == RPC_X_NULL_REF_POINTER),
|
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
|
|
|
|
"RPC_X_NULL_REF_POINTER)\n", res, GetLastError());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* with a valid buffer, but level is invalid */
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = GetPrintProcessorDirectoryA(NULL, NULL, 2, buffer, cbBuf, &pcbNeeded);
|
|
|
|
|
if (res && buffer[0])
|
|
|
|
|
{
|
|
|
|
|
/* Level is ignored in win9x*/
|
|
|
|
|
trace("invalid level (2) was ignored\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
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-06-09 21:54:19 +02:00
|
|
|
|
res, GetLastError());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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());
|
|
|
|
|
|
|
|
|
|
/* invalid on all Systems */
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
/* invalid on all Systems */
|
|
|
|
|
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);
|
2006-06-09 21:54:19 +02: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",
|
2006-06-09 21:54:19 +02:00
|
|
|
|
res, GetLastError());
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
res = OpenPrinter(NULL, NULL, NULL);
|
2006-12-14 17:59:46 +01:00
|
|
|
|
/* The deactivated Spooler is caught here on NT3.51 */
|
2006-02-02 13:50:36 +01:00
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
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);
|
|
|
|
|
res = OpenPrinter(NULL, &hprinter, NULL);
|
2006-12-14 17:59:46 +01:00
|
|
|
|
/* The deactivated Spooler is caught here on XPsp2 */
|
2006-02-02 13:50:36 +01:00
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
2005-12-12 13:02:15 +01:00
|
|
|
|
ok(res || (!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);
|
|
|
|
|
res = OpenPrinter(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);
|
|
|
|
|
res = OpenPrinter(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);
|
|
|
|
|
res = OpenPrinter(local_server, &hprinter, NULL);
|
2005-12-12 13:02:15 +01:00
|
|
|
|
ok(res || (!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);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = OpenPrinter(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);
|
2006-08-19 17:15:59 +02:00
|
|
|
|
res = OpenPrinter(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
|
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
res = OpenPrinter(default_printer, &hprinter, NULL);
|
2006-02-02 13:50:36 +01:00
|
|
|
|
if((!res) && (GetLastError() == RPC_S_SERVER_UNAVAILABLE))
|
|
|
|
|
{
|
2006-05-11 19:57:48 +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);
|
|
|
|
|
res = OpenPrinter(default_printer, NULL, NULL);
|
|
|
|
|
/* 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);
|
|
|
|
|
res = OpenPrinter(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);
|
|
|
|
|
res = OpenPrinter(default_printer, &hprinter, &defaults);
|
2006-02-23 16:03:32 +01:00
|
|
|
|
/* stop here, when a remote Printserver has no RPC-Service running */
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
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);
|
|
|
|
|
res = OpenPrinter(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);
|
|
|
|
|
res = OpenPrinter(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];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!pSetDefaultPrinterA) return;
|
|
|
|
|
/* only supported on win2k and above */
|
|
|
|
|
|
|
|
|
|
/* backup the original value */
|
|
|
|
|
org_value[0] = '\0';
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = GetProfileStringA("windows", "device", NULL, org_value, size);
|
|
|
|
|
|
|
|
|
|
/* first part: with the default Printer */
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = pSetDefaultPrinterA("no_printer_with_this_name");
|
|
|
|
|
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
/* spooler is running or we have no spooler here*/
|
|
|
|
|
|
|
|
|
|
/* 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("");
|
|
|
|
|
ok(res || (!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);
|
|
|
|
|
ok(res || (!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);
|
|
|
|
|
ok(res || (!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("");
|
|
|
|
|
/* we get ERROR_INVALID_PRINTER_NAME when no printer is installed */
|
|
|
|
|
ok(res || (!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 */
|
|
|
|
|
ok(res || (!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);
|
|
|
|
|
ok(res || (!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 */
|
|
|
|
|
res = pSetDefaultPrinterA(default_printer); /* the nice way */
|
|
|
|
|
WriteProfileStringA("windows", "device", org_value); /* the old way */
|
|
|
|
|
|
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
SetLastError(MAGIC_DEAD);
|
|
|
|
|
res = GetProfileStringA("windows", "device", NULL, buffer, size);
|
|
|
|
|
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);
|
|
|
|
|
res = OpenPrinter(xcv_localport, &hXcv, &pd);
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_MonitorUIW, NULL, 0, NULL, 0, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, emptyW, NULL, 0, NULL, 0, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_MonitorUIW, NULL, 0, buffer, len, NULL, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_MonitorUIW, NULL, 0, NULL, len, &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);
|
|
|
|
|
|
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_MonitorUIW, NULL, 0, buffer, len, &needed, NULL);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_MonitorUIW, NULL, 0, buffer, len+1, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_MonitorUIW, NULL, 0, buffer, len-1, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_MonitorUIW, NULL, 0, buffer, len, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = OpenPrinter(xcv_localport, &hXcv, &pd);
|
|
|
|
|
|
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(res)
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W), NULL, 0, NULL, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_PortIsValidW, (PBYTE) emptyW, sizeof(emptyW), NULL, 0, &needed, &status);
|
|
|
|
|
ok( res && (status == ERROR_PATH_NOT_FOUND),
|
|
|
|
|
"returned %d with %u and %u for status %u (expected '!= 0' for ERROR_PATH_NOT_FOUND)\n",
|
|
|
|
|
res, GetLastError(), needed, status);
|
|
|
|
|
|
|
|
|
|
/* a directory is not allowed */
|
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_PortIsValidW, (PBYTE) tempdirW, (lstrlenW(tempdirW) + 1) * sizeof(WCHAR), NULL, 0, &needed, &status);
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
|
|
/* more valid well known Ports */
|
|
|
|
|
needed = (DWORD) 0xdeadbeef;
|
|
|
|
|
status = (DWORD) 0xdeadbeef;
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt1W, sizeof(portname_lpt1W), NULL, 0, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_PortIsValidW, (PBYTE) portname_lpt2W, sizeof(portname_lpt2W), NULL, 0, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_PortIsValidW, (PBYTE) portname_com1W, sizeof(portname_com1W), NULL, 0, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_PortIsValidW, (PBYTE) portname_com2W, sizeof(portname_com2W), NULL, 0, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_PortIsValidW, (PBYTE) portname_fileW, sizeof(portname_fileW), NULL, 0, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
res = pXcvDataW(hXcv, cmd_PortIsValidW, (PBYTE) tempfileW, (lstrlenW(tempfileW) + 1) * sizeof(WCHAR), NULL, 0, &needed, &status);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ########################### */
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
trace("There is no default printer installed, skiping the test\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hprn = 0;
|
|
|
|
|
ret = OpenPrinter(default_printer, &hprn, NULL);
|
|
|
|
|
if (!ret)
|
|
|
|
|
{
|
|
|
|
|
trace("There is no printers installed, skiping the test\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ok(hprn != 0, "wrong hprn %p\n", hprn);
|
|
|
|
|
|
|
|
|
|
for (level = -1; level <= 7; level++)
|
|
|
|
|
{
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
needed = (DWORD)-1;
|
|
|
|
|
ret = GetPrinterDriver(hprn, NULL, level, NULL, 0, &needed);
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
|
filled = -1;
|
|
|
|
|
ret = GetPrinterDriver(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)
|
|
|
|
|
{
|
|
|
|
|
DRIVER_INFO_2 *di_2 = (DRIVER_INFO_2 *)buf;
|
|
|
|
|
DWORD calculated = sizeof(*di_2);
|
|
|
|
|
|
2006-05-02 05:58:36 +02:00
|
|
|
|
/* MSDN is wrong: The Drivers on the win9x-CD's have cVersion=0x0400
|
|
|
|
|
NT351: 1, NT4.0+w2k(Kernelmode): 2, w2k and above(Usermode): 3 */
|
|
|
|
|
ok((di_2->cVersion >= 0 && di_2->cVersion <= 3) ||
|
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;
|
|
|
|
|
|
|
|
|
|
/* 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);
|
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
|
|
|
|
|
2006-04-18 12:36:58 +02:00
|
|
|
|
static void test_DEVMODE(const DEVMODE *dm, LONG dmSize, LPCSTR exp_prn_name)
|
|
|
|
|
{
|
2006-05-02 00:03:51 +02:00
|
|
|
|
/* On NT3.51, some fields in DEVMODE are empty/zero
|
|
|
|
|
(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 */
|
|
|
|
|
ok(!strncmp(exp_prn_name, (LPCSTR)dm->dmDeviceName, CCHDEVICENAME -1),
|
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;
|
|
|
|
|
DEVMODE *dm;
|
|
|
|
|
|
|
|
|
|
if (!default_printer)
|
|
|
|
|
{
|
|
|
|
|
trace("There is no default printer installed, skiping the test\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hprn = 0;
|
|
|
|
|
ret = OpenPrinter(default_printer, &hprn, NULL);
|
|
|
|
|
if (!ret)
|
|
|
|
|
{
|
|
|
|
|
trace("There is no printers installed, skiping the test\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ok(hprn != 0, "wrong hprn %p\n", hprn);
|
|
|
|
|
|
|
|
|
|
dm_size = DocumentProperties(0, hprn, NULL, NULL, NULL, 0);
|
2006-10-13 13:20:32 +02:00
|
|
|
|
trace("DEVMODE required size %d\n", dm_size);
|
|
|
|
|
ok(dm_size >= sizeof(DEVMODE), "unexpected DocumentProperties ret value %d\n", dm_size);
|
2006-04-18 12:36:58 +02:00
|
|
|
|
|
|
|
|
|
dm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dm_size);
|
|
|
|
|
|
|
|
|
|
ret = DocumentProperties(0, hprn, NULL, dm, dm, DM_OUT_BUFFER);
|
2006-10-13 13:20:32 +02:00
|
|
|
|
ok(ret == IDOK, "DocumentProperties ret value %d != expected IDOK\n", ret);
|
2006-04-18 12:36:58 +02:00
|
|
|
|
|
|
|
|
|
test_DEVMODE(dm, dm_size, default_printer);
|
|
|
|
|
|
|
|
|
|
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);
|
2007-01-15 05:38:47 +01:00
|
|
|
|
RETURN_ON_DEACTIVATED_SPOOLER(ret)
|
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))
|
|
|
|
|
{
|
|
|
|
|
trace("EnumPrintersW is not implemented, skipping some tests\n");
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-15 01:50:48 +01:00
|
|
|
|
START_TEST(info)
|
|
|
|
|
{
|
2005-12-12 13:02:15 +01:00
|
|
|
|
hwinspool = GetModuleHandleA("winspool.drv");
|
|
|
|
|
pGetDefaultPrinterA = (void *) GetProcAddress(hwinspool, "GetDefaultPrinterA");
|
2006-02-20 11:51:10 +01: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();
|
2006-11-07 00:07:48 +01:00
|
|
|
|
test_ConfigurePort();
|
2006-04-16 02:42:34 +02:00
|
|
|
|
test_DeleteMonitor();
|
2006-11-28 00:48:04 +01:00
|
|
|
|
test_DeletePort();
|
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-02-02 00:46:03 +01:00
|
|
|
|
test_EnumPrinters();
|
2006-02-01 12:32:10 +01:00
|
|
|
|
test_GetDefaultPrinter();
|
|
|
|
|
test_GetPrinterDriverDirectory();
|
2006-06-09 21:54:19 +02:00
|
|
|
|
test_GetPrintProcessorDirectory();
|
2006-02-01 12:32:10 +01:00
|
|
|
|
test_OpenPrinter();
|
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();
|
2003-01-15 01:50:48 +01:00
|
|
|
|
}
|