mhamini
Member level 1
- Joined
- Aug 23, 2005
- Messages
- 40
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- Iran-Tehran
- Activity points
- 1,690
I have a board that communicates with my computer thru the USB and it appears on my computer as a virtual com port. I am trying to make an existing MFC program that I made work with the board. I have code in my program that goes through the com ports to find and list all the available com ports. The code looks like this:
char sPort [6] = "COMX";
for (int index = 0; index < 16; index++) // Find available Com Ports
{
HANDLE hPort = INVALID_HANDLE_VALUE;
sprintf(sPort, "COM%i", index+1);
hPort = CreateFile (sPort,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
0);
if ( INVALID_HANDLE_VALUE != hPort)
{
// port exists...
m_ctlComPortBox.AddString(sPort); // Add available Com Port to IDC_ANISETTING_COMPORT
CloseHandle ( hPort);
}
}
The problem is, that it isn't finding the virtual Com ports. Are there changes that I can do to make it detect the virtual ports or is there another method that might work? By the way, my board is coming up as com 13 if that means anything.
char sPort [6] = "COMX";
for (int index = 0; index < 16; index++) // Find available Com Ports
{
HANDLE hPort = INVALID_HANDLE_VALUE;
sprintf(sPort, "COM%i", index+1);
hPort = CreateFile (sPort,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
0);
if ( INVALID_HANDLE_VALUE != hPort)
{
// port exists...
m_ctlComPortBox.AddString(sPort); // Add available Com Port to IDC_ANISETTING_COMPORT
CloseHandle ( hPort);
}
}
The problem is, that it isn't finding the virtual Com ports. Are there changes that I can do to make it detect the virtual ports or is there another method that might work? By the way, my board is coming up as com 13 if that means anything.