使用SetupDiGetDeviceRegistryProperty获取驱动器类型 [英] Get drive type with SetupDiGetDeviceRegistryProperty

查看:2986
本文介绍了使用SetupDiGetDeviceRegistryProperty获取驱动器类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我是否可以使用



SP_DEVICE_INTERFACE_DETAIL_DATA的DevicePath



my设备路径如下所示



\?\usb#vid_04f2& pid_0111#5& 39fe81e& 0& 2#{a5dcbf10-6530-11d2-901f-00c04fb951ed }



也请在winapi中告诉我们要确定驱动器是否是USB驱动器,请调用SetupDiGetDeviceRegistryProperty并指定SPDRP_REMOVAL_POLICY属性。 p>

我也使用SetupDiGetDeviceRegistryProperty如下

  while(!SetupDiGetDeviceRegistryProperty(hDevInfo, & DeviceInfoData,
SPDRP_REMOVAL_POLICY,& DataT,(PBYTE)buffer,buffersize,& buffersize))

但我不知道如何获得驱动器类型使用上述..



请帮助我

nofollow> http://support.microsoft.com/kb/264203/en 。 http://support.microsoft.com/kb/305184/en 的另一个链接可以是

http://support.microsoft.com/kb/264203/en 显示如何使用确定USB驱动器是否可移动。您还可以在设备实例上使用 SetupDiGetDeviceRegistryProperty SPDRP_REMOVAL_POLICY (使用 SetupDiEnumDeviceInfo SetupDiGetDeviceInstanceId ,然后 SetupDiGetDeviceRegistryProperty )。如果返回 DWORD 具有 CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL CM_REMOVAL_POLICY_EXPECT_ORDERLY_REMOVAL 驱动器是可移除的。



此外,代码示例显示如何打开设备句柄,您可以使用 DeviceIoControl 函数检索您可能需要的大量有用的信息。 IOCTL_STORAGE_QUERY_PROPERTY (请参阅 http://msdn.microsoft.com/en-us/library/ff566997%28v=VS.85%29.aspx )与不同的 QueryType PropertyId 只有一个示例。您可以使用 IOCTL_STORAGE_GET_DEVICE_NUMBER 来接收存储卷及其磁盘号。



如果您将拥有< c $ c> STORAGE_DEVICE_NUMBER 有关您的USB设备的信息,我们将能够以不同的方式查找有关它的所有其他信息。最简单的方法之一是:只需使用QueryDosDevice枚举所有驱动器号,并为每个驱动器查询 STORAGE_DEVICE_NUMBER 。如果您在 STORAGE_DEVICE_NUMBER 中找到完整匹配,您会找到驱动器号。


I would like to know whether i can get the drive information using the

SP_DEVICE_INTERFACE_DETAIL_DATA's DevicePath

my device path looks like below

"\?\usb#vid_04f2&pid_0111#5&39fe81e&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}"

also please tell me in the winapi they say "To determine whether a drive is a USB-type drive, call SetupDiGetDeviceRegistryProperty and specify the SPDRP_REMOVAL_POLICY property."

i too use SetupDiGetDeviceRegistryProperty like below

while ( !SetupDiGetDeviceRegistryProperty( hDevInfo,&DeviceInfoData,
    SPDRP_REMOVAL_POLICY,&DataT,( PBYTE )buffer,buffersize,&buffersize ))

but i dont know how can i get the drive type using the above..

Please help me up

解决方案

Probably what you are looking for you will be find here http://support.microsoft.com/kb/264203/en. Another link http://support.microsoft.com/kb/305184/en can be also interesting for you.

UPDATED: Example from http://support.microsoft.com/kb/264203/en shows you how to use to determine whether USB-Drive is removable. You can also use SetupDiGetDeviceRegistryProperty with SPDRP_REMOVAL_POLICY on the device instance (use SetupDiEnumDeviceInfo, SetupDiGetDeviceInstanceId and then SetupDiGetDeviceRegistryProperty). If returned DWORD has CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL or CM_REMOVAL_POLICY_EXPECT_ORDERLY_REMOVAL as value, the drive is removable.

Moreover the code example show how to open device handle which you can use with DeviceIoControl function to retrieve a lot of useful information which you can need. IOCTL_STORAGE_QUERY_PROPERTY (see http://msdn.microsoft.com/en-us/library/ff566997%28v=VS.85%29.aspx) with different QueryType and PropertyId only one example. You can use IOCTL_STORAGE_GET_DEVICE_NUMBER for example to receive storage volumes and their disk number.

If you will have full STORAGE_DEVICE_NUMBER information about your USB device we will be able to find all other information about it with different ways. One of the easiest is: just enumerate all drive letters with QueryDosDevice and query STORAGE_DEVICE_NUMBER for every drive. If you will find full match in STORAGE_DEVICE_NUMBER you will find the drive letter.

这篇关于使用SetupDiGetDeviceRegistryProperty获取驱动器类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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