How to force close the serial port?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.