답변이 좀 늦었네요. 다들 세번째 인자가 0 이면, 공유를 할 수 없다는 말이던데요..
쩝.. 공유를 할 수 없다는 부분이 지배적이던데.. 장치가 없으니 실험해 볼수도 없구요.. :)
아무튼.. 저도 Good Luck 입니다요~
I'd be curious whar other program is currently sharing the USB port. If
that other program has already opened the port for exclusive access then I
think there's not much you can do other than to close that other program.
I'm also not sure about the exclusive access for comm ports in the case of
USB. Are USB ports considered comm ports? Or only Com1 and Com2, etc.?
Perhaps search the internet for USB information. I'll bet someone has
posted more on this topic. Good luck.
Rgs,
sjc
> I wrote some program that uses USB port. I used following command, but USB
> port was shared by another program.
>
> hCom = CreateFile(\\\\.\\USB002,
> GENERIC_READ | GENERIC_WRITE,
> 0, // comm devices must be opened w/exclusive-access <------ is it effectable?
> NULL, // no security attrs
> OPEN_EXISTING, // comm devices must use OPEN_EXISTING
> 0, // not overlapped I/O
> NULL // hTemplate must be NULL for comm devices
> );
>
> My machine may not share with another program. So, I've tried open USB port
> with exclusive mode, But, It seems be no effect.
>
> Do I have to process another work~?
>
> Thank you
>
> Chris You
>
>
> Chris You Software Engineer - Man & Tech
> 6F SamhwanCamus B/D, 17w/3 Youido, YoungDung-Po Ku Seoul, Korea.
> Phone : +82 (0)2 761-6560 (241) Fax : +82 (0)2 761-6561 Mobile : +82 (0)11
> 729-6449
> e-mail : cuperido@mail.com homepage :
http://www.cuperido.pe.kr/
김형덕 님이 쓰신 글 :
: 자체 개발한 USB보드를 사용하여
: 현재 프로젝트가 진행중입니다.
: 근데 이런 프로그램을 2개 띄워도 CreateFile을 하면 프로그램
: 2개다 핸들을 얻습니다.
: CreateFile에 있는 각종 옵션 Share를 0으로 해도 핸들을 얻어
: 하나의 장치를 두 프로그램이 공유를 해버립니다.
: 그러면 안돼는 장비인데...
: 어떻게 하면 장치하나당 하나의 CreateFile할수 있도록
: Lock할수 있을까요
: 살려주세요