problem in getting modem status

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a problem in getting the status of the modem. Here is my code:

HANDLE hfile;
DCB dcb;

hfile = CreateFile("BCM V.92 56K Modem", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);

i(hfile != INVALID_HANDLE_VALUE)
{
GetCommState(hfile, &dcb);
}

This code is very simple, but it is not working. The CreateFile call can return correct handle, but the GetCommState call always fails. Can you help me figure out the problem? Thank you very much!
 
David said:
hfile = CreateFile("BCM V.92 56K Modem", GENERIC_READ,
0, NULL, OPEN_EXISTING, 0, NULL);

i(hfile != INVALID_HANDLE_VALUE)
{
GetCommState(hfile, &dcb);
}

This code is very simple, but it is not working.

You need to pass the name of a COMM port to CreateFile(), something along
the lines of

"\\\\.\\COM1"

Note that I have doubled-up on the backslashes because the character is an
"escape" in C or C++ source. The actual name of the device is

\\.\COMn

where n is the unit number of the device.

Regards,
Will
 
Back
Top