等同于“扫描硬件更改”;安装失败后在设备管理器中无法正常工作 [英] Equivalent of "Scan For Hardware Changes" in device manager doesn't work after failed installation

查看:129
本文介绍了等同于“扫描硬件更改”;安装失败后在设备管理器中无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 docs C ++函数 CfgMgr32.dll 的CM_Locate_DevNodeA CM_Reenumerate_DevNode 应该与菜单项在设备管理器中扫描更改的硬件

According to the docs the C++ functions CM_Locate_DevNodeA and CM_Reenumerate_DevNode of CfgMgr32.dll should be the programatical equivalant to the menu item scan for changed hardware in the device manager.

请参见针对C#中托管代码的第二个问题

但是与文档相反,程序化方法设备管理器操作有效时,它并不总是起作用。这是我的情况:

But in contrary to the docs, the programmatical approach doesn't work always, when the Device manager operation works. This is my case:


  1. 用户已插入USB设备

  1. User already plugged in the USB device

找不到驱动程序

我的安装程序将正确的INF文件添加到
Windows / inf目录

My installer adds the right INF-File into the Windows/inf directory

CM_Reenumerate_DevNode 不会导致安装新驱动程序

CM_Reenumerate_DevNode doesn't cause the installation of the new driver

在设备管理器中,Wheras扫描硬件更改使用新的驱动程序开始
安装

Wheras "Scan for hardware changes" in device manager starts the installation with the new driver


推荐答案

在尝试编写C ++代码以复制设备管理器的扫描硬件命令时,我遇到了类似的问题。

I had a similar issue trying to write C++ code to replicate the Device Manager's Scan For Hardware command.

我尝试使用 https://support.microsoft.com/en-us/kb/259697

但是,它没有用。我注意到 CM_Reenumerate_DevNode 返回了 CR_ACCESS_DENIED ,它是 #define CR_ACCESS_DENIED(0x00000033)//仅NT Cfgmrg32.h 中的

However, it didn't work. I noticed CM_Reenumerate_DevNode returned CR_ACCESS_DENIED, which is #define CR_ACCESS_DENIED (0x00000033) // NT ONLY in Cfgmrg32.h.

根据 CM_Reenumerate_DevNode函数,此函数的调用者需要 SeLoadDriverPrivilege

According to CM_Reenumerate_DevNode function, callers of this function need SeLoadDriverPrivilege.

为了避免在代码中设置此特权,我通过右键单击以管理员身份运行.exe。 exe,然后选择以管理员身份运行。

To get around setting this privilege in code, I ran the .exe as an administrator by right-clicking on .exe and selecting Run as administratror.

这篇关于等同于“扫描硬件更改”;安装失败后在设备管理器中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆