Access non-exposed port.
-
Hi, I am working on VS 2005 on Vista platform. I have an mobile data card which exposes an Modem Port and this port appears as an device entry under "Modems" in the Device Manager. In addition to this, the device has another port which i figured out by scanning through the registry and this port does not appear in the device manager. This port appears in the list of available ports displayed by HyperTerminal and also in PortMon and I can connect and talk to the device via HyperTerminal. But in my application when I try to do an CreateFile with that port name, the call fails with GetLastError() returning 2.
TCHAR szPortName\[MAX\_PATH\]=\_T(""); \_tcscpy(szPortName, \_T("\\\\\\\\.\\\\")); \_tcscat(szPortName, \_T("COM6:"); //assume the non-exposed port is COM6. HANDLE hDeviceFile = CreateFile(szPortName, GENERIC\_READ | GENERIC\_WRITE, 0, NULL, OPEN\_EXISTING, 0, NULL); DWORD dwReturn = GetLastError();
Is there something wrong in the CreateFile() function call above. Or is it that Vista allows only ports that are expose/displayed in the Device Manager for an Device to be used by an application?
-
Hi, I am working on VS 2005 on Vista platform. I have an mobile data card which exposes an Modem Port and this port appears as an device entry under "Modems" in the Device Manager. In addition to this, the device has another port which i figured out by scanning through the registry and this port does not appear in the device manager. This port appears in the list of available ports displayed by HyperTerminal and also in PortMon and I can connect and talk to the device via HyperTerminal. But in my application when I try to do an CreateFile with that port name, the call fails with GetLastError() returning 2.
TCHAR szPortName\[MAX\_PATH\]=\_T(""); \_tcscpy(szPortName, \_T("\\\\\\\\.\\\\")); \_tcscat(szPortName, \_T("COM6:"); //assume the non-exposed port is COM6. HANDLE hDeviceFile = CreateFile(szPortName, GENERIC\_READ | GENERIC\_WRITE, 0, NULL, OPEN\_EXISTING, 0, NULL); DWORD dwReturn = GetLastError();
Is there something wrong in the CreateFile() function call above. Or is it that Vista allows only ports that are expose/displayed in the Device Manager for an Device to be used by an application?
Found the problem. I was specifying Port Name as _T("COM6:") while the correct was is _T("COM6") i.e, without the colon at the end.