A Windows XP help forum. PCbanter

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.

Go Back   Home » PCbanter forum » Microsoft Windows XP » Hardware and Windows XP
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

COM port not opening



 
 
Thread Tools Display Modes
  #1  
Old October 7th 10, 02:46 PM posted to microsoft.public.windowsxp.hardware
Alain Dekker[_2_]
external usenet poster
 
Posts: 64
Default 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  
Old October 7th 10, 03:11 PM posted to microsoft.public.windowsxp.hardware
Paul
external usenet poster
 
Posts: 18,275
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off






All times are GMT +1. The time now is 01:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.