winapicom0com

com0com virtual port not found


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.

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.


Solution

  • Here are my points:

    SoftWx has written an interesting tutorial on installing it on a 64 bit Windows 7 machine. You can fetch it here.

    UPDATE:

    Signed version available since 2017-07-13.