简体   繁体   English

COM端口以编程方式禁用/启用C#

[英]Com port Disable/Enable Programmatically C#

Where i can get the instance id of Com_port? 在哪里可以获取Com_port的实例ID? I tried in device manager but those are not working 我在设备管理器中尝试过,但是那些没有用

string instance_Path = @"VID_12D1&PID_140C&MI_02";
DeviceHelper.SetDeviceEnabled(mouseGuid, instance_Path, true);

This question is virtually a duplicate - Win32 API function to programmatically enable/disable device 这个问题实际上是重复的-Win32 API函数以编程方式启用/禁用设备

"mouseGuid" might be pasted from there. 可能会从此处粘贴“ mouseGuid”。 I suppose you're specifying a wrong GUID for the COM port. 我想您为COM端口指定了错误的GUID。 You can see the correct one in the Device Manager, Details tab -> choose "Class Guid" from the dropdown menu. 您可以在“设备管理器”的“详细信息”选项卡中找到正确的选项->从下拉菜单中选择“ Class Guid”。

Having troubles messing with WinAPI, you can use a library (eg Hardware Helper ) or an external tool ( DevCon ). 使用WinAPI时遇到麻烦,您可以使用库(例如Hardware Helper )或外部工具( DevCon )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM