If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
COM port not opening
I'm trying to get access to a COM Port using this code:
HANDLE hCom = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); This works almost all the time...but on this one machine we have it keeps failing (hCOM == -1). Device Manager shows the com port looks fine. I've tried changing COM1 to COM2 without success. Any ideas? Is it relevant whether I use "COM1" or "\\\\.\\COM1" ? Thanks, Alain |
Ads |
#2
|
|||
|
|||
COM port not opening
Alain Dekker wrote:
I'm trying to get access to a COM Port using this code: HANDLE hCom = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL); This works almost all the time...but on this one machine we have it keeps failing (hCOM == -1). Device Manager shows the com port looks fine. I've tried changing COM1 to COM2 without success. Any ideas? Is it relevant whether I use "COM1" or "\\\\.\\COM1" ? Thanks, Alain Throw your code into a search engine, and look for examples ? http://vbnet.mvps.org/index.html?cod...comtestapi.htm Paul |
Thread Tools | |
Display Modes | |
|
|