I have installed, apparently successfully, com0com v2.2.2.0 on a 64bit Windows 7 machine.
I run the command utility, like this:
command> install PortName=COM9 PortName=COM8
CNCA0 PortName=COM9
CNCB0 PortName=COM8
ComDB: COM8 - logged as "in use"
ComDB: COM9 - logged as "in use"
command> busynames COM?*
COM3
COM4
COM5
COM6
COM8
COM9
COMPOSITEBATTERY
Note: logged as "in use" is NOT an error message?
Then I try to open COM8 like this
m_hIDComDev = CreateFileA( szCodedPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL );
if( m_hIDComDev == NULL || m_hIDComDev == INVALID_HANDLE_VALUE ) {
wchar_t * lpMsgBuf;
DWORD dw = ::GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
myErrorMsg = (char*)malloc( 200 );
sprintf(myErrorMsg,"Error creating connection %s ( %s ) %S",
szPort,szCodedPort,lpMsgBuf);
This fails with
Error creating connection COM8 ( COM8 ) The system cannot find the file specified.
I have tried both "COM8" and "\\.\COM8"
.
Note that the exact same call to CreateFileA works perfectly on a 'real' COM port.
Q: Can someone tell me what the problem is?
A: On windows 7 64 bit you have to enable testing of unsigned drivers.
Run a command prompt as administrator. ( It is not enough just to run from an account with admin privileges. See here for details of how to do this. )
Type in the command
bcdedit -set TESTSIGNING ON
reboot. ( Windows will place a "test Mode" note on the bottom right of the desktop )
For Windows 8 this method does not work satisfactorily or easily. Here is some discussion of the issues and workarounds.
Alternatively you might want to try a signed version - I have NOT tried this myself.
In case anyone is referencing this, and interested in this topic, the 2.2.2.0 version of com0com is signed for 64-bit Windows. This removes the need to jump through the hoops of putting Windows in "test" mode.
Here are my points:
64-bit drivers
to besigned
.com0com.sys
(64bit) is a mere unsigned kernel-mode driver.SoftWx has written an interesting tutorial on installing it on a 64 bit Windows 7 machine. You can fetch it here.