Board index » delphi » COM: port above 9 in W2K/NT4????

COM: port above 9 in W2K/NT4????

I am trying to extend a Delphi 4 component for serial port handling to
use higher port numbers than 9 but I fail at this. :-(

The function that is used inside the component is the API call
CreateFile and the parameter passed as lpFileName for com ports 1-9 is
COM1, COM2 etc. When I try to extend this above 9 for example setting
the name to COM12 then CreateFile returns with an error code (cannot
find file specified) and the port is not opened.

Since I am no Win32 programming expert I need some pointer to what I
am doing wrong here. Or maybe CreateFile cannot be used for the higher
numbered com ports? (I do have comports 9-12 available for example
from Hyper terminal).

TIA

Bo Berglund
Software developer in Sweden
bo.bergl...@telia.com

PGP: My public key is available at the following locations:
Idap://certserver.pgp.com
http://pgpkeys.mit.edu:11371

 

Re:COM: port above 9 in W2K/NT4????


Quote
On Fri, 26 May 2000 21:24:42 GMT, Bo Berglund wrote:
>I am trying to extend a Delphi 4 component for serial port handling to
>use higher port numbers than 9 but I fail at this. :-(

>The function that is used inside the component is the API call
>CreateFile and the parameter passed as lpFileName for com ports 1-9 is
>COM1, COM2 etc. When I try to extend this above 9 for example setting
>the name to COM12 then CreateFile returns with an error code (cannot
>find file specified) and the port is not opened.

>Since I am no Win32 programming expert I need some pointer to what I
>am doing wrong here. Or maybe CreateFile cannot be used for the higher
>numbered com ports? (I do have comports 9-12 available for example
>from Hyper terminal).

Use a name like \\.\COM10.  The \\.\ part is optional for ports 1-9,
required for ports 10 and up.

--
"The privileged being which we call human is distinguished from other
animals only by certain double-edged manifestations which in charity we
can only call 'inhuman.'" -- Epiktistes

Re:COM: port above 9 in W2K/NT4????


Im Artikel <392ee914.1739670...@nntpserver.swip.net>, bo.bergl...@telia.com (Bo
Berglund) schreibt:

Quote
>the name to COM12 then CreateFile returns with an error code (cannot
>find file specified) and the port is not opened.

Look into the system properties to find out the names of the excess ports?

DoDi

Re:COM: port above 9 in W2K/NT4????


On 28 May 2000 01:13:49 GMT, vb...@aol.com (VBDis) wrote:

Quote
>Im Artikel <392ee914.1739670...@nntpserver.swip.net>, bo.bergl...@telia.com (Bo
>Berglund) schreibt:

>>the name to COM12 then CreateFile returns with an error code (cannot
>>find file specified) and the port is not opened.

>Look into the system properties to find out the names of the excess ports?

Not really,
as was pointed out by David Rifkind the proper com port names should
be \\.\COM<number>, only for ports 1-9 is one allowed to use the
shorter syntax. Probably because of backwards compatibility issues.
The correct naming system works for ALL ports so I have changed the
string generation in the component accordingly and it now works as it
should.
Thanks David!

Bo Berglund
Software developer in Sweden
bo.bergl...@telia.com

PGP: My public key is available at the following locations:
Idap://certserver.pgp.com
http://pgpkeys.mit.edu:11371

Other Threads