开发者

How to close an opened serial port?

suppose an application (not me!) has opened a Serial port (COM1) , and i do not have access to it's handle (or something like that) and i don't know... now, how can i close and release 开发者_如何学Pythonit by C# or C++? thanks.


This will be like trying to force close a file that another application has opened. It is generally not a good thing to do, as the other application that had opened the port will stop working.

There is a tool called Process Explorer that can do what you are trying to achieve, so I guess that this is feasible. However, you should forget managed code and probably need to look at very low-lever API to do it.


There's a Windows API function called CloseHandle(HANDLE hObject). if we have the handle of file / port opened , then we can close it. thanks everyone...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜