How to force close the serial port? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiAPI/html/delphi_20061110085745262.html
Other systems Program How can I forcibly disable the serial port used?
Thank you.
API:
Closefile
Closehandle
How to use it? Can you give a detailed example?
How can I get handle from the serial port? If it is com1. sorry, I am not familiar with it.
VaR
Hcom: thandle; handle of the comport
// ================================
// Open
// Open COM1 in read/write mode
Hcom: = createfile ('com1'), generic_read or generic_write,
0, nil, open_existing, 0, 0 );
// Close
Closehandle (hcom );
Let's take a look at the question again. The landlord wants to shut down the serial port opened by other programs. That doesn't work. Well, at least I won't.
Oh, no.
Oh, neither will I.
Can I disable the process that uses the serial port?
Hehe, thank you Comanche (terrible ).
I want to close the COM port opened by other programs
That is to say, when starting my program, it is forced to close regardless of the COM port status.
I have found many posts. Some people say that they can only use APIs to disable the serial port service and then start the service.
But I did not find any service in the system for serial port for a long time.
If another program opens the serial port exclusively, you do not know handle. How can this problem be solved?
Find the handle of the process and close it !!
Unplug the device from the serial port
Why not read my message:
You can only use APIs to disable the serial port service and then start the service.
But I did not find any service in the system for serial port for a long time.
Other methods may not work. You need to disable the serial port service. In this way, all serial ports are closed and then the service is started.
Can I delete the driver or port to achieve this goal?
Ddd
Turn off the computer
To extcsdn (studing VB now
Good way, but the customer won't accept it.