简体   繁体   English

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

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

I have tried to disable com port by using 我试图通过使用禁用COM端口

Microsoft.Win32.Registry.SetValue(
    @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR",
    "Start",
    4,
    Microsoft.Win32.RegistryValueKind.DWord
); 

//enable USB storage...
Microsoft.Win32.Registry.SetValue(
    @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR",
    "Start",
    3,
    Microsoft.Win32.RegistryValueKind.DWord
);

but doesn't work in 64 bit pc. 但不适用于64位电脑。

Is there any other solution to disable com port in 64 bit? 有没有其他解决方案来禁用64位的COM端口?

Eugh. Eugh。 Don't do this. 不要这样做。 Use SetupDiSetClassInstallParams or WMI + devcon or really anything other than editing the registry! 使用SetupDiSetClassInstallParamsWMI + devcon或除编辑注册表以外的其他任何方法!

But to use registry you need to specify RegistryView.Registry64 , or clear the Prefer 32 bit flag in the project properties 但是要使用注册表,您需要指定RegistryView.Registry64 ,或清除项目属性中的Prefer 32 bit标志

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

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