相关疑难解决方法(0)

为什么SetupDiEnumDriverInfo为我的驱动程序提供两个版本号

我试图以编程方式获取驱动程序的版本号.似乎是通过使用SetupDiEnumDriverInfo获取SP_DRVINFO_DATA结构并检查它来完成的DriverVersion field.

以下代码有效,但为同一驱动程序返回两个不同的版本.我的设备是一个自定义USB设备,带有一个.sys文件.我的机器只连接了一台设备.我指定DIGCF_PRESENT只查询当前连接的设备的驱动程序.

int main(void)
{
    // Get the "device info set" for our driver GUID
    HDEVINFO devInfoSet = SetupDiGetClassDevs(
                              &GUID_DEVINTERFACE_USBSPI, NULL, NULL,
                              DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);

    // Cycle through all devices currently present
    for (int i = 0; ; i++)
    {
        // Get the device info for this device
        SP_DEVINFO_DATA devInfo;
        devInfo.cbSize = sizeof(SP_DEVINFO_DATA);
        if (!SetupDiEnumDeviceInfo(devInfoSet, i, &devInfo))
            break;

        // Build a list of driver info items that we will retrieve below …
Run Code Online (Sandbox Code Playgroud)

c c++ windows driver

4
推荐指数
1
解决办法
2297
查看次数

标签 统计

c ×1

c++ ×1

driver ×1

windows ×1