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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top