在设备管理器中重置设备

发布于 2024-09-29 16:18:21 字数 70 浏览 2 评论 0原文

我正在寻找一个关于如何重新启动任何允许在设备管理器中启用/禁用的设备的编程 API,

例如音频设备和网络适配器

I am looking for a programmically API on how to restart any device that allows enable/disable in the device manager,

such as Audio devices and Network adapter

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

dawn曙光 2024-10-06 16:18:21

您必须使用 SetupApi / < a href="http://msdn.microsoft.com/en-us/library/ff549794(v=VS.85).aspx" rel="nofollow">ConfigManager API。但请注意,在 x64 下您的应用程序。也必须是 x64 才能启用/禁用设备(所以你现在不能直接在 Delphi 中执行此操作 - 首先我认为这是 x64 下 x86-app 的文件/注册表重定向问题,但它没有帮助)。设备枚举工作正常。 MSDN 上的一篇文章中有关于它的内容,但我现在找不到它。我制作了 FP/Lazarus x64 应用程序,用于在 x64 操作系统下启用/禁用设备。

您可以下载WDK并查找DevCon (C:\WinDDK\7600.16385.1\src\setup\devcon)。在 cmds.cpp 中,有一个 ControlCallback 函数,它可以使用 SetupApi 启用/禁用设备。但首先需要枚举设备类(通过 GUID 或 ClassName),然后通过 DeviceInstanceId 字符串枚举设备实例或打开设备。它是用 C 编写的,但学习如何使用该 API 应该很容易。

不确定你在做什么,但也许使用 devcon.exe (不知道许可证是否允许)并通过它启用/禁用设备会更容易?

You will have to use SetupApi / ConfigManager API. But be aware that under x64 you app. must be also x64 to enable/disable device (so you cannot do it in Delphi directly right now - first I thought that it's a problem with file/registry redirection for x86-app under x64, but it didn't help). Device enumeration works fine. There was something about it in one article on MSDN but I cannot find it right now. I've made FP/Lazarus x64 application for enable/disable devices under x64 OS.

You can download WDK and look for source code of DevCon (C:\WinDDK\7600.16385.1\src\setup\devcon). In cmds.cpp there is function ControlCallback which enables/disables device using SetupApi). But first you need to enumerate device classes (by GUID or ClassName), and then enumerate device instances or open device by DeviceInstanceId string. It's in C but it should be easy to learn how to use that API.

Not sure what you are doing, but maybe it would be easier to use that devcon.exe (don't know if license permits it) and enable/disable devices by it?

时间海 2024-10-06 16:18:21

我没有这方面的经验,但我认为你可以使用 DeviceIoControl API。

I have no experience with it but I think you can use the DeviceIoControl API.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文