如何禁用特定的usb端口com2 c#64位

How to disable a specific usb port com2 c# 64 bit

本文关键字:端口 com2 c#64 usb 何禁用      更新时间:2023-10-16

我尝试使用禁用com端口

Microsoft.Win32.Registry.SetValue(
    @"HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesUSBSTOR",
    "Start",
    4,
    Microsoft.Win32.RegistryValueKind.DWord
); 
//enable USB storage...
Microsoft.Win32.Registry.SetValue(
    @"HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesUSBSTOR",
    "Start",
    3,
    Microsoft.Win32.RegistryValueKind.DWord
);

但在64位pc 中不起作用

有没有其他解决方案可以在64位中禁用com端口?

Eugh。不要这样做。使用SetupDiSetClassInstallParams或WMI+devcon或除编辑注册表之外的任何其他功能!

但要使用注册表,您需要指定RegistryView.Registry64,或清除项目属性中的Prefer 32位标志