如何禁用系统设备?

How do I disable a system device?(如何禁用系统设备?)

本文介绍了如何禁用系统设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从 C#.NET 禁用系统设备.

基本上是在您进入设备管理器并以这种方式禁用设备时进行模拟?

我假设有一个可以调用的 WinAPI 函数,但我不知道它是哪一个?

我需要这样做的原因是我需要禁用并在再次启用设备后立即.

我需要在 Windows XP 和 Vista(x86 和 x64)中工作.我查看了一个名为DevCon"的东西,但它似乎不适用于 Vista x64.

谢谢.

有关答案,请参见此处:如何禁用以编程方式的系统设备?

解决方案

进一步 Mel Green 的回答是,硬件帮助程序库使用互操作调用 Windows API (setupapi),特别是 SetupDiSetClassInstallParams 方法.当然这里还有其他调用,用于查找设备详细信息等.

需要考虑的一点是,如果您以标准用户或非特权帐户运行,您将无法使用它来控制(启用/禁用等)硬件设备.

有关更多详细信息,请查看 http://www.pinvoke.net(以及具体调用: http://pinvoke.net/default.aspx/setupapi.SetupDiSetClassInstallParam )p>

Is there any way to disable a system device from C#.NET.

Basically emulating when you go to Device Manager and disable a device that way?

I am assuming there is a WinAPI function that I can invoke, but I don't know which one it is?

The reason I need to do this is that I need to disable and straight after enable the device again.

I need to work in Windows XP and Vista (x86 & x64). I had a look at something called "DevCon" but it doesn't seem to work on Vista x64.

Thanks.

For the answer see here: How do I disable a system device programatically?

解决方案

To futher Mel Green's answer, the hardware helper library uses interop to call the Windows API (setupapi), specifically the SetupDiSetClassInstallParams method. Of course there are other calls here which are used to look up the device details etc.

One thing to consider that if you are running as a standard user or unprivileged account you will not be able to use this to control (enable/disable etc) hardware devices.

For more details have a look at http://www.pinvoke.net (and for the specific call: http://pinvoke.net/default.aspx/setupapi.SetupDiSetClassInstallParam )

这篇关于如何禁用系统设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何禁用系统设备?

基础教程推荐