使用SetupDi系列函数

SetupDiGetClassDevs-使用SetupDi系列函数进行设备信息的管理(一)

 
枚举设备信息SetupDiGetClassDevs
HDEVINFO SetupDiGetClassDevs(
IN PGUID ClassGuid,
IN PCTSTR Enumerator,
IN HWND hwndParent,
IN DWORD Flags
);
SetupDiGetClassDevs 获取一个指定类别或全部类别的所有已安装设备的信息

参数说明:

ClassGuid

一个特定类别GUID(需要查询注册表)的指针,如果设置了DIGCF_ALLCLASSES标记,该参数备忽略,将返回所有类别的设备信息表

 

Enumerator

过滤梅举的内容:如:PCI则只显示PCI设备,

 

hwndParent

用于关联到集合成员中的用户接口的顶层窗口句柄

Flags

建立设备信息表的控制选项,可以是下列值

DIGCF_PRESENT

(只列出当前存在的设备信息)

 

DIGCF_ALLCLASSES

(列出所有类别的一安装的设备表,如果设置了此值,则指定的类别将备忽略)

 

DIGCF_PROFILE

(只返回当前硬件概况部分)

Return Value

如成功,返回包含所有与指定参数匹配的已经安装设备信息句柄

 

如失败则返回INVALID_HANDLE_VALUE


SetupDiEnumDeviceInfo-使用SetupDi系列函数进行设备信息的管理(二)

 

BOOLEAN
SetupDiEnumDeviceInfo(
IN HDEVINFO DeviceInfoSet,
IN DWORD MemberIndex,
OUT PSP_DEVINFO_DATA DeviceInfoData
);

SetupDiEnumDeviceInfo 枚举指定设备信息集合的成员,并将数据放在PSP_DEVINFO_DATA中
参数说明:

DeviceInfoSet
提供一个设备信息集合的句柄

MemberIndex
指定一个要取得的设备信息成员序号,从0开始

DeviceInfoData
指向SP_DEVINFO_DATA结构的指针,关于指定成员的返回信息就放在该结构中

Return ValueThe

成功返回True,否则返回False)

如果要枚举全部设备信息成员,装载者首先应该将MemberIndex设为0调用SetupDiEnumDeviceInfo,然后递增MemberIndex(使用一个for循环),调用SetupDiEnumDeviceInfo,直至所有成员全部遍历(此时函数返回False,并且GetLastError返回ERROR_NO_MORE_ITEMS)


SetupDiGetDeviceRegistryProperty-使用SetupDi系列函数进行设备信息的管理(三)

 

WINSETUPAPI BOOL WINAPI
SetupDiGetDeviceRegistryProperty(
IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData,
IN DWORD Property,
OUT PDWORD PropertyRegDataType, OPTIONAL
OUT PBYTE PropertyBuffer,
IN DWORD PropertyBufferSize,
OUT PDWORD RequiredSize OPTIONAL
);

SetupDiGetDeviceRegistryProperty:获得单个装置的详细资料

参数说明:

DeviceInfoSet

设备信息句柄

DeviceInfoData

SP_DEVINFO_DATA结构体,包含DeviceInfoSet 中的设备信息

Property

取以下的值:

SPDRP_ADDRESS

查询设备的地址

SPDRP_BUSNUMBER

查询设备的bus号

SPDRP_BUSTYPEGUID

查询设备的GUID号

SPDRP_CAPABILITIES

The function retrieves a bitwise OR of the following CM_DEVCAP_Xxx flags in a DWORD. The device capabilities that are represented by these flags correspond to the device capabilities that are represented by the members of the DEVICE_CAPABILITIES structure. The CM_DEVCAP_Xxx constants are defined in cfgmgr32.h.

CM_DEVCAP_Xxx flagCorresponding DEVICE_CAPABILITIES structure member
CM_DEVCAP_LOCKSUPPORTED LockSupported
CM_DEVCAP_EJECTSUPPORTED EjectSupported
CM_DEVCAP_REMOVABLE Removable
CM_DEVCAP_DOCKDEVICE DockDevice
CM_DEVCAP_UNIQUEID UniqueID
CM_DEVCAP_SILENTINSTALL SilentInstall
CM_DEVCAP_RAWDEVICEOK RawDeviceOK
CM_DEVCAP_SURPRISEREMOVALOK SurpriseRemovalOK
CM_DEVCAP_HARDWAREDISABLED HardwareDisabled
CM_DEVCAP_NONDYNAMIC NonDynamic
SPDRP_CHARACTERISTICS
The function retrieves a bitwise OR of a device's characteristics flags in a DWORD. For a description of these flags, which are defined in wdm.h and ntddk.h, see the  IoCreateDevicefunction's  DeviceCharacteristics parameter.
SPDRP_CLASS
The function retrieves a REG_SZ string that contains the device setup class of a device.
SPDRP_CLASSGUID
The function retrieves a REG_SZ string that contains the GUID that represents the device setup class of a device.
SPDRP_COMPATIBLEIDS
The function retrieves a REG_MULTI_SZ string containing the list of compatible IDs for a device. For information about compatible IDs, see Device Identification Strings.
SPDRP_CONFIGFLAGS
The function retrieves a bitwise OR of a device's configuration flags in a DWORD value. The configuration flags are represented by the CONFIGFLAG_ Xxx bitmasks that are defined in  regstr.h.
SPDRP_DEVICE_POWER_DATA
(Windows XP and later) The function retrieves a CM_POWER_DATA structure containing the device's power management information.
SPDRP_DEVICEDESC
The function retrieves a REG_SZ string containing the description of a device.
SPDRP_DEVTYPE
The function retrieves a DWORD value representing the device's type (see Specifying Device Types).
SPDRP_DRIVER
The function retrieves a string identifying the device's software key (sometimes called the  driver key). See Driver Information in the Registry.
SPDRP_ENUMERATOR_NAME
The function retrieves a REG_SZ string containing the name of the device's enumerator.
SPDRP_EXCLUSIVE
The function retrieves a DWORD value that indicates whether a user can obtain exclusive use of the device. The returned value is one if exclusive use is allowed, or zero otherwise. For more information, see  IoCreateDevice.
SPDRP_FRIENDLYNAME
The function retrieves a REG_SZ string that contains the friendly name of a device.
SPDRP_HARDWAREID
The function retrieves a REG_MULTI_SZ string containing the list of hardware IDs for a device. For information about hardware IDs, see Device Identification Strings.
SPDRP_INSTALL_STATE
(Windows XP and later) The function retrieves a DWORD value that indicates the installation state of a device. The installation state is represented by one of the CM_INSTALL_STATE_ Xxx values that are defined in  Cfgmgr32.h. The CM_INSTALL_STATE_ Xxx values correspond to the DEVICE_INSTALL_STATE enumeration values.
SPDRP_LEGACYBUSTYPE
The function retrieves the device's legacy bus type as an INTERFACE_TYPE value (defined in  wdm.hand  ntddk.h).
SPDRP_LOCATION_INFORMATION
The function retrieves a REG_SZ string that contains the hardware location of a device.
SPDRP_LOCATION_PATHS
(Windows Server 2003 and later) The function retrieves a REG_MULTI_SZ string that represents the location of the device in the device tree.
SPDRP_LOWERFILTERS
The function retrieves a REG_MULTI_SZ string that contains the names of a device's lower-filter drivers.
SPDRP_MFG
The function retrieves a REG_SZ string that contains the name of the device manufacturer.
SPDRP_PHYSICAL_DEVICE_OBJECT_NAME
The function retrieves a REG_SZ string that contains the name that is associated with the device's PDO. For more information, see  IoCreateDevice.
SPDRP_REMOVAL_POLICY
(Windows XP and later) The function retrieves the device's current removal policy as a DWORD containing one of the CM_REMOVAL_POLICY_ Xxx values defined in  cfgmgr32.h.
SPDRP_REMOVAL_POLICY_HW_DEFAULT
(Windows XP and later) The function retrieves the device's hardware-specified default removal policy as a DWORD containing one of the CM_REMOVAL_POLICY_ Xxx values defined in  cfgmgr32.h.
SPDRP_REMOVAL_POLICY_OVERRIDE
(Windows XP and later) The function retrieves the device's override removal policy (if it exists) from the registry, as a DWORD containing one of the CM_REMOVAL_POLICY_ Xxx values defined in cfgmgr32.h.
SPDRP_SECURITY
The function retrieves a SECURITY_DESCRIPTOR structure for a device.
SPDRP_SECURITY_SDS
The function retrieves a REG_SZ string that contains the device's security descriptor. The format of security descriptor strings is described in Microsoft Windows SDK documentation.
SPDRP_SERVICE
The function retrieves a REG_SZ string containing the service name for a device.
SPDRP_UI_NUMBER
The function retrieves a DWORD value set to the value of the  UINumber member of the device's DEVICE_CAPABILITIES structure.
SPDRP_UI_NUMBER_DESC_FORMAT
The function retrieves a format string (REG_SZ) used to display the  UINumber value.
SPDRP_UPPERFILTERS
The function retrieves a REG_MULTI_SZ string that contains the names of a device's upper filter drivers.
PropertyRegDataType
A pointer to a variable that receives the data type of the property that is being retrieved. This is one of the standard registry data types. This parameter is optional and can be NULL.
PropertyBuffer
A pointer to a buffer that receives the property that is being retrieved. If this parameter is set to NULL, and  PropertyBufferSize is also set to zero, the function returns the required size for the buffer in  RequiredSize.
PropertyBufferSize
The size, in bytes, of the  PropertyBuffer buffer.
RequiredSize
A pointer to a variable of type DWORD that receives the required size, in bytes, of the PropertyBuffer buffer that is required to hold the data for the requested property. This parameter is optional and can be NULL.
Return Value

SetupDiGetDeviceRegistryProperty returns TRUE if the call was successful. Otherwise, it returns FALSE and the logged error can be retrieved with a call to GetLastError.SetupDiGetDeviceRegistryProperty returns the ERROR_INVALID_DATA error code if the requested property does not exist for a device or if the property data is not valid.


SetupDiDestroyDeviceInfoList-使用SetupDi系列函数进行设备信息的管理(四)

 

The SetupDiDestroyDeviceInfoList 销毁一个设备信息集合,并且释放所有关联的内存

<p style="margin-top: 0px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(70, 70, 70); font-family: simsun; font-size: 14px; background-color: rgb(188, 211, 229);">销毁一个设备信息集合,并且释放所有关联的内存</p><p style="margin-top: 0px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(70, 70, 70); font-family: simsun; font-size: 14px; background-color: rgb(188, 211, 229);"><strong>BOOL <span style="font-family:Courier New;word-wrap: normal; word-break: normal;"><span style="word-wrap: normal; word-break: normal; background-color: rgb(255, 255, 255);">SetupDiDestroyDeviceInfo<wbr>List</wbr></span>(</span> HDEVINFO</strong> <em><a target=_blank href="http://hi.baidu.com/fc/editor/" style="text-decoration: none; color: rgb(62, 115, 160);">DeviceInfoSet</a></em><strong> );</strong></p>
Parameters
DeviceInfoSet
[in]要释放的设备信息句柄
Return Values

成功返回非零,否则返回



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值