Where i can get the instance id of Com_port? 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
"mouseGuid" might be pasted from there. I suppose you're specifying a wrong GUID for the COM port. You can see the correct one in the Device Manager, Details tab -> choose "Class Guid" from the dropdown menu.
Having troubles messing with WinAPI, you can use a library (eg Hardware Helper ) or an external tool ( DevCon ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.