We help IT Professionals succeed at work.

Which UNIT do I need to add to uses for 'CloseHandle' ?

ChLa
ChLa asked
on
Medium Priority
112 Views
Last Modified: 2019-11-14
I am using Delphi from within Rad Studio 10.2 to write a small program to see exactly how to talk to a device via USB. The device will appear as a Com port. I have a working shell for my program and started to write in the details for how to open, configure, write to, and close a port. I started with close because it is the smallest. I am getting the error message undeclared identifier 'CloseHandle'. Is there a UNIT I need to add to USES ?
Comment
Watch Question

Senior Developer
CERTIFIED EXPERT
Commented:
Well, seems like you haven't done this before.. In this case the "best" start is by looking into Dejan's pretty complete Com implementation for Delphi:

https://sourceforge.net/projects/comport/
ChLaProducer

Author

Commented:
Hi,
I need help. I am trying to compile the Comport pas file. I have loaded it into Delphi and now I am supposed to hit compile in the package window. I cannot find a package window or a compile button.
ste5anSenior Developer
CERTIFIED EXPERT

Commented:
ChLaProducer

Author

Commented:
Thanks for the link. I have read the manual, about 2 decades ago when they used to print them. I was not able to absorb or even understand all of it. But I have been programming successfully with Delphi for a long time. This sort of thing is out of my range of experience and so I sometimes need some help. I haven't compiled .dpk files before.
Which .dpk file(s) do I compile for RAD Studio 10.2  ?
ste5anSenior Developer
CERTIFIED EXPERT

Commented:
Did you read the readme of the comport library ?
ChLaProducer

Author

Commented:
Yes I did. It is not very explicit regarding Delphi 10.2. My guess is that I need to compile either CPortLibD2010.dpk, or, CPortLibDXE.dpk. My confusion stems from the fact that I don't know if DX refers to Delphi versions later than 2010, or if it refers to a light version of Delphi. I like to be sure about these things so I don't make any mistakes.
ste5anSenior Developer
CERTIFIED EXPERT

Commented:
DXE means Delphi XE.

Just test it, errors and mistakes are a source of wisdom and knowledge.
ChLaProducer

Author

Commented:
I compiled, built and installed CPortLibDXE.dpk and DsgnCPortDXE.dpk. Now I have six Cport components in my component library. I just ran the Comport Library example and it is able to communicate with my device. I should be able to continue form here. compiling, building and installing was easy.
thank you very much for your help.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.