hi,
in the first process i need to create the handle to a serial port
("COM1"), and in the first process, i need to open this port.

i'm using the code above:

m_hFile = ::CreateFile("COM1",
GENERIC_READ|GENERIC_WRITE,

FILE_SHARE_READ|FILE_SHARE_WRITE,
0,
OPEN_EXISTING,
1?FILE_FLAG_OVERLAPPED:0,
0);

to create its ok, but when the second process will open the serial, i
take a ACCESS_DENIED (code 5 in getLastError)

what can i do to solve this problem?

Re: CreateFile to open a COM in two different process by Maxim

Maxim
Tue Aug 08 18:09:27 CDT 2006

Serial port is exclusive, and can be opened only by 1 process a time.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

<lgbrito@gmail.com> wrote in message
news:1155057557.838955.199610@p79g2000cwp.googlegroups.com...
> hi,
> in the first process i need to create the handle to a serial port
> ("COM1"), and in the first process, i need to open this port.
>
> i'm using the code above:
>
> m_hFile = ::CreateFile("COM1",
> GENERIC_READ|GENERIC_WRITE,
>
> FILE_SHARE_READ|FILE_SHARE_WRITE,
> 0,
> OPEN_EXISTING,
> 1?FILE_FLAG_OVERLAPPED:0,
> 0);
>
> to create its ok, but when the second process will open the serial, i
> take a ACCESS_DENIED (code 5 in getLastError)
>
> what can i do to solve this problem?
>