Answered by:
addmonitor fails on vista 64

Question
-
I have made an application that adds a port monitor using the addmonitor windows function. It runs fine on Windows XP. On Vista Ultimate 64 I manually copy the port monitor dll to c:\windows\system32, when I try to execute the application as administrator the addmonitor function returns FALSE. Any idea what is wrong?
The application is as follows:
int
_tmain(int argc, _TCHAR* argv[]){
MONITOR_INFO_2 mi;
mi.pName = _T(
mi.pEnvironment =
_T("Windows NT x86");//NULL;mi.pDLLName = _T(
"testport.dll");BOOL rc = AddMonitor(NULL, 2, (LPBYTE)&mi); // this fails for Windows Vista, but works on Windows XP
if (rc)
{
::AddPort(NULL, NULL, _T("Test Port"));
}
return 0;
}
Sunday, October 21, 2007 8:57 PM
Answers
-
Monday, October 22, 2007 8:01 PM
All replies
-
Couple of things. Use GetLastError to find out what the actual failure value is.
I note that your environment is set to Windows NT x86, shouldn't it be Windows x64.
Monday, October 22, 2007 5:33 PM -
I retried with the environment set to "Windows x64". GetLastError() returns error 193, ERROR_BAD_EXE_FORMAT.
The application is build on a 32-bit Windows XP system. Isn't the WOW64 emulator able to run this application?
In that case I would have to build one 32-bit and one 64-bit version of the setup application, and let an installer determine the if the platform is 32 or 64-bit and run the corresponding application.
Monday, October 22, 2007 7:20 PM -
The testport.dll port monitor is also build on a 32-bit system. I guess the print spooler on a 64-bit system will be unable to load a 32-bit dll; I would have to build a 32-bit and 64-bit version of the dll and let a installer decide which dll to install on a system.
Monday, October 22, 2007 7:26 PM -
Monday, October 22, 2007 8:01 PM