Problem with ExtEscape() function on Server 2003



I am wondering why the ExtEscape() function works on Win2000 and WinXP to
send an escape code to the video driver, but it does not work under Server
2003. On Server 2003 I get a return code of 0 which indicates an error, but
without any error information (which isn't very helpful).

I wrote a small test program (below) that sends the QUERYESCSUPPORT command
to the driver. It works on XP and 2000, but fails on Server 2003, even on the
same dual-boot computer. I got the same result on two different computers
running Server 2003. QUERYESCSUPPORT is the most basic command (it just
checks to see if other commands are supported) so it should be supported by
every video driver.

I am working in a multimonitor environment, so I am trying to send the
command to a specific driver that is attached to the desktop. However, the
problem happens even on a single monitor computer.

One idea I had was that Server 2003 might have some security policy that
prevents driver commands, but that doesn't really make sense, and I'm logged
on as admin.

Thanks in advance!

Martin
604.839.2330


#include <windows.h>
#include <iostream>

using namespace std;

typedef struct _DISPLAY_DEVICE2
{
DWORD cb;
WCHAR DeviceName[32];
WCHAR DeviceString[128];
DWORD StateFlags;
WCHAR DeviceID[128];
WCHAR DeviceKey[128];
} DISPLAY_DEVICE2, *PDISPLAY_DEVICE2;

typedef BOOL (WINAPI * EnumDisplayDevicesW_t)(
PVOID Unused,
DWORD iDevNum,
PDISPLAY_DEVICE2 lpDisplayDevice,
DWORD dwFlags);

void
wmain(int argc, wchar_t *argv[])
{
// This first bit of code just prints a list of the monitors in your
system.
//
// You can use this list to determine whether your device name is
"DISPLAY1" or
// "DISPLAY2" etc.

DISPLAY_DEVICE2 dd;

HMODULE h = ::LoadLibrary(L"user32.dll");
EnumDisplayDevicesW_t fnEnumDisplayDevices =
(EnumDisplayDevicesW_t)::GetProcAddress(h, "EnumDisplayDevicesW");

int i = 0;
while (true)
{
::ZeroMemory(&dd, sizeof(dd));
dd.cb = sizeof(dd); // Do this each iteration or the stack gets
trashed.

if (!fnEnumDisplayDevices(NULL, i, &dd, 0))
break;

wcout << dd.DeviceName << L" " << dd.DeviceString << endl;

i += 1;
}

// This next bit of code attempts to send an escape command to the video
driver. The
// following methods of opening the device contect all seem to produce
the same
// results.
//
// This code works on Win2000 and XP SP2 but not on Win 2003 Server.
//
// Its rather odd that the first one works, since it doesn't specify
which display
// device to use. I figure that Windows sends the escape code to all
devices that are
// part of the virtual desktop.
//
// On my computer, the main video driver is "DISPLAY1". Your computer
might differ.

HDC hdc = ::CreateDC(NULL, L"\\\\.\\DISPLAY1", NULL, NULL);
// HDC hdc = ::CreateDC(L"DISPLAY", NULL, NULL, NULL);
// HDC hdc = ::CreateDC(L"DISPLAY", L"\\\\.\\DISPLAY1", NULL, NULL);
// HDC hdc = ::CreateDC(L"\\\\.\\DISPLAY1", L"\\\\.\\DISPLAY1", NULL,
NULL);

if (hdc == NULL)
{
wcout << L"Could not create DC. Error " << ::GetLastError() << endl;
}
else
{
// The following code queries whether the QUERYESCSUPPORT command is
supported.
// It should always return true!
//
// It fails on Windows Server 2003. I always get a return code of 0
and a last
// error value of 0, not very useful.

int cmd = QUERYESCSUPPORT;
char output[1000];

int n = ::ExtEscape(hdc, QUERYESCSUPPORT, sizeof(cmd), (char *)&cmd,
sizeof(output), (char *)output);

if (n > 0)
wcout << L"Escape command supported." << endl;
else
wcout << L"Escape command not supported. Return code " << n <<
L". Last error " << ::GetLastError() << endl;

::DeleteDC(hdc);
}
}




.



Relevant Pages

  • [2.6 patch] the scheduled eepro100 removal
    ... This patch contains the scheduled removal of the eepro100 driver. ... First set is undocumented and spelled per Intel recommendations. ... -static int use_io; ... Each Tx command block ...
    (Linux-Kernel)
  • [2.6 patch] the overdue eepro100 removal
    ... This patch contains the overdue removal of the eepro100 driver. ... First set is undocumented and spelled per Intel recommendations. ... -static int use_io; ... Each Tx command block ...
    (Linux-Kernel)
  • [2.6.24 patch] the planned eepro100 removal
    ... This patch contains the planned removal of the eepro100 driver. ... First set is undocumented and spelled per Intel recommendations. ... -static int use_io; ... Each Tx command block ...
    (Linux-Kernel)
  • [2.6.24 patch] the planned eepro100 removal
    ... This patch contains the planned removal of the eepro100 driver. ... First set is undocumented and spelled per Intel recommendations. ... -static int use_io; ... Each Tx command block ...
    (Linux-Kernel)
  • [2.6.24 patch] the planned eepro100 removal
    ... This patch contains the planned removal of the eepro100 driver. ... First set is undocumented and spelled per Intel recommendations. ... -static int use_io; ... Each Tx command block ...
    (Linux-Kernel)