PC Review


Reply
Thread Tools Rate Thread

COM port not opening

 
 
Alain Dekker
Guest
Posts: n/a
 
      7th Oct 2010
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


 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      7th Oct 2010
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
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening Port? Pegleg Windows XP Help 1 28th Dec 2006 06:10 AM
Opening a DNS port John Smith Microsoft Windows 2000 Networking 5 23rd Feb 2006 05:23 AM
opening a port Steffo Windows XP General 3 19th Dec 2004 06:44 PM
Opening a port randyb Microsoft Windows 2000 Security 9 5th Aug 2004 04:02 AM
Re: opening port 20, 21 Wesley Vogel Windows XP Security 0 1st Apr 2004 12:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:26 PM.