Serial interfacing with Win32 console app

Hi All,

Quick question to those of you who have gotten a USB Arduino board talking with a Windows console application. Can anyone spot what I'm doing wrong here? The code below works fine with my USB->Serial adapter based around the Prolific chip, but can't seem to find the port when used with my Arduino. The Arduino host software communicates fine with the board. This code, however, consistently returns ERROR_FILE_NOT_FOUND. Any thoughts?

HANDLE hSerial;
hSerial = CreateFile("COM15",
GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
if (hSerial == INVALID_HANDLE_VALUE)
{
if (GetLastError() == ERROR_FILE_NOT_FOUND)
{
printf("port does not exist");
return 0;
}
printf("some other error");
return 0;
}

Here is a snippet of code from one of my C++ programs for opening a com port as a handle.
You have to open it as "\.\com1" for example. Of course in C++, a backslash in a string has to be doubled to avoid it being treated as an escape sequence (gee, thanks Microsoft, for not using "/" like Unix does!).

            char comport_name [64];
            sprintf (comport_name, "\\\\.\\COM%d", comport);
            HANDLE comhandle = CreateFileA (
                comport_name,
                GENERIC_READ | GENERIC_WRITE,
                0,                  // no sharing
                NULL,               // default security attributes
                OPEN_EXISTING,
                FILE_ATTRIBUTE_NORMAL,
                NULL
            );

That seems to be working nicely. Not sure why my way was working for the other board, though..

Cheers.