SetupDiBuildDriverInfoList需要很长时间 [英] SetupDiBuildDriverInfoList takes a long time

查看:184
本文介绍了SetupDiBuildDriverInfoList需要很长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从C ++获取某些设备的驱动程序版本。部分代码如下所示。我的问题是,SetupDiBuildDriverInfoList例程需要很长时间(大约2秒),你有什么建议可以帮我解决这个问题吗?



I was trying to get the driver version of some devices from C++. part of the code is listed as below.My question is, the SetupDiBuildDriverInfoList routine, takes a long time(about 2 seconds),do you have any suggestions that would help me with this problem?

HDEVINFO DevInfoSet = SetupDiGetClassDevs(&Guid, NULL, NULL, DIGCF_DEVICEINTERFACE);

SP_DEVINFO_DATA devInfo;
devInfo.cbSize = sizeof(SP_DEVINFO_DATA);
cr = CM_Get_Device_ID_Ex(dn, Buffer, BufferSize, 0, m_hMachine);
PCWSTR devID = Buffer;
cr = SetupDiOpenDeviceInfo(DevInfoSet, devID, NULL, DIOD_INHERIT_CLASSDRVS, &devInfo);


cr = SetupDiBuildDriverInfoList(DevInfoSet, &devInfo, SPDIT_COMPATDRIVER);
	
SP_DRVINFO_DATA drvInfo;
drvInfo.cbSize = sizeof(SP_DRVINFO_DATA);
cr = SetupDiEnumDriverInfo(DevInfoSet, &devInfo, SPDIT_COMPATDRIVER, 0, &drvInfo);

推荐答案

可能的来源可能是有许多设备与提供给SetupDiGetClassDevs function [ ^ ]。您应该尝试通过调整参数来限制设备数量。



提供具体提示需要知道传递的 ClassGuid 参数以及应该查询哪种接口。



但这里有一些(请参阅上面的MSDN链接):



  • 如果可以使用枚举器参数。
  • 添加 DIGCF_PRESENT 标志以忽略不存在的设备。
  • 可选择使用 DIGCF_DEFAULT 标志,并在此失败时重试。
A possible source may be that there are many devices that match the parameters supplied to the SetupDiGetClassDevs function[^]. You should try to limit the number of devices by tuning the parameters.

Giving specific tips requires knowing the passed ClassGuid parameter and which kind of interfaces should be queried.

But here are some (please see also the above MSDN link):

  • If possible use the Enumerator parameter.
  • Add the DIGCF_PRESENT flag to ignore non-present devices.
  • Optionally use the DIGCF_DEFAULT flag and retry without when this fails.


这篇关于SetupDiBuildDriverInfoList需要很长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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