SetupDi系列函数
SetupDiClassGuidsFromName
WINSETUPAPI BOOL SetupDiClassGuidsFromNameA( PCSTR ClassName,
LPGUID ClassGuidList,
DWORD ClassGuidListSize,
PDWORD RequiredSize );
SetupDiClassGuidsFromName函数检索与指定类名关联的GUID。
ClassName:要检索的GUID的类名字;
ClassGuidList:一个数组的指针,以获得与指定类名称关联的GUID列表;
ClassGuidListSize:ClassGuidList列表数组中GUID的数量;
RequiredSize :提供一个指向变量的指针,该变量接收与类名关联的guid数。如果这个数字大于ClassGuidList缓冲区的大小,那么这个数字表示为了存储所有的guid,数组必须有多大。
返回值:
如何调用成功返回TRUE,失败返回FALSE;
SetupDiGetClassDevs
WINSETUPAPI HDEVINFO SetupDiGetClassDevsW( const GUID *ClassGuid,
PCWSTR Enumerator,
HWND hwndParent,
DWORD Flags );
该函数返回一个设备信息集的句柄看,该设备信息集包含本地计算机所请求的设备信息元素。
参数:
ClassGuid:一个指向设备安装类或设备接口类的GUID的指针;该指针是随意的也可以为空。
Enumerator:一个指向空字符结尾的字符串,列举如下:
即插即用设备枚举树的ID,此ID既可以是全局唯一标识符(GUID)也可以是符号名称。比如:“PCI”可以用于指定PCI的PnP值,符号名称则包括像“USB”,“PCMCIA”和“SCSI”这样的Pnp值。
一个PnP设备句柄ID。当指定了一个PnP设备句柄ID时,DIGCF_DEVICEINTERFACE必须在Flag参数上被设置。
hwndParent:用于与在设备信息集中安装设备实例相关联的用户界面的顶级窗口句柄。该句柄是可选的,并且可以为NULL。
Flags : Flags是一个DWORD类型的变量,通过此参数来过滤指定的设备信息集中的设备。此参数可以是以下标志位中的一个或多个的按位或组合。
DIGCF_ALLCLASSES
返回所有已安装设备的列表或所有设备接口类。
DIGCF_DEVICEINTERFACE
返回支持指定设备接口类的设备。如果Enumerators参数制定了设备的实例ID,那么必须在Flags参数中设置此标志位。
DIGCF_DEFAULT
对于指定的设备接口类,只返回与系统默认设备接口相关联的设备(如果已设置的话)。
DIGCF_PRESENT
只返回当前系统中存在的(已连接)设备。
DIGCF_PROFILE
只返回当前硬件列表中的一部分设备。
返回值
如果调用成功,SetupDiGetClassDevs将返回一个设备信息集的句柄,该句柄包含了与所提供参数所匹配的所有设备。如果调用失败,函数返回INVALID_HANDLE_VALUE。要进一步获取错误信息,请调用GetLastError。
SetupDiEnumDeviceInfo 函数
WINSETUPAPI BOOL SetupDiEnumDeviceInfo( HDEVINFO DeviceInfoSet,
DWORD MemberIndex,
PSP_DEVINFO_DATA DeviceInfoData );
说明:
功能:返回一个SP_DEVINFO_DATA结构体,这个结构体是在一个设备信息集中指定的一个设备信息元素
反复的调用该函数会返回不同设备的设备信息元素。
枚举设备信息元素,最初调用该函数时要将MemberIndex参数设置为0,然后每次调用递增MemberIndex参数的值,直到没有更多设备的设备信息元素返回(即
SetupDiEnumDeviceInfo函数调用失败,使用GetLastError函数会返回ERROR_NO_MORE_ITEMS);
参数:
DeviceInfoSet:设备信息集的句柄,用于返回表示设备信息元素的PSP_DEVINFO_DATA 数据结构。
MemberIndex:要检索的从零开始的设备信息元素。
DeviceInfoData :指向PSP_DEVINFO_DATA 数据结构的指针,用于接收关于枚举设备信息元素的信息。调用者必须设置DeviceInfoData。
cbSize设置成sizeof(PSP_DEVINFO_DATA )。
返回值:
如果成功返回TRUE,失败返回FALSE;
SetupDiGetDeviceRegistryProperty 函数
WINSETUPAPI BOOL SetupDiGetDeviceRegistryPropertyA( HDEVINFO DeviceInfoSet,
PSP_DEVINFO_DATA DeviceInfoData,
DWORD Property,
PDWORD PropertyRegDataType,
PBYTE PropertyBuffer,
DWORD PropertyBufferSize,
PDWORD RequiredSize );
该函数用于检索一个指定的即插即用设备的属性;
参数:
DeviceInfoSet:指向一个设备信息集的指针,表示要检索即插即用属性的设备。
DeviceInfoData:一个PSP_DEVINFO_DATA 结构体,指定DeviceInfoSet中的设备信息元素。
Property:以下要被检索的指定属性:
SPDRP_ADDRESS
The function retrieves the device's address.
SPDRP_BUSNUMBER
The function retrieves the device's bus number.
SPDRP_BUSTYPEGUID
The function retrieves the GUID for the device's bus type.
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 flag | Corresponding 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 DeviceCharacteristics parameter of the IoCreateDevice function.
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 that contains 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 that contains the device's power management information.
SPDRP_DEVICEDESC
The function retrieves a REG_SZ string that contains the description of a device.
SPDRP_DEVTYPE
The function retrieves a DWORD value that represents the device's type. For more information, see Specifying Device Types.
SPDRP_DRIVER
The function retrieves a string that identifies the device's software key (sometimes called the driver key). For more information about driver keys, see Registry Trees and Keys for Devices and Drivers.
SPDRP_ENUMERATOR_NAME
The function retrieves a REG_SZ string that contains 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 that contains 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_Xxxvalues 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.h and 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 that contains one of the CM_REMOVAL_POLICY_Xxx values that are 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 that contains one of the CM_REMOVAL_POLICY_Xxx values that are 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 that contains one of the CM_REMOVAL_POLICY_Xxx values that are 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. For information about security descriptor strings, see Security Descriptor Definition Language (Windows). For information about the format of security descriptor strings, see Security Descriptor Definition Language (Windows).
SPDRP_SERVICE
The function retrieves a REG_SZ string that contains 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:指向一个变量的指针,该变量接收正在检索的属性的数据类型。这是标准注册表数据类型之一。此参数是可选的,可以为空。
PropertyBuffer:一个指向缓冲区的指针,该缓冲区接收要检索的属性。如果将该参数设置为NULL,并将PropertyBufferSize设置为0,则函数将在RequiredSize中返回 缓冲区所需的大小。
PropertyBufferSize:属性缓冲区大小;
RequiredSize:指向类型为DWORD的变量的指针,该变量接收PropertyBuffer缓冲区所需大小(以字节为单位),该缓冲区用于保存所请求属性的数据。此参数是可选 的,可以为空
返回值:
如果调用成功返回TRUE,失败返回FALSE;
SetupDiOpenDevRegKey
WINSETUPAPI HKEY SetupDiOpenDevRegKey( HDEVINFO DeviceInfoSet,
PSP_DEVINFO_DATA DeviceInfoData,
DWORD Scope,
DWORD HwProfile,
DWORD KeyType,
REGSAM samDesired );
SetupDiOpenDevRegKey函数为特定设备的配置信息打开注册表项。
参数:
DeviceInfoSet:设备信息集的句柄,该句柄包含一个设备信息元素,该元素表示要为其打开注册表项的设备。
DeviceInfoData:一个指向SP DEVINFO数据结构的指针,该结构指定DeviceInfoSet中的设备信息元素。
Scope:要打开的注册表项的范围。范围决定信息存储在何处。范围可以是全局的,也可以是特定于硬件配置文件的。范围由下列值之一指定:
DICS_FLAG_GLOBAL
打开存储全局配置信息的键值项。此信息并不特定于特定的硬件配置文件。这将打开一个根在 HKEY_LOCAL_MACHINE。打开的确切键取决于KeyType的值。
DICS_FLAG_CONFIGSPECIFIC
打开存储特定于硬件概要文件的配置信息的键值项。此键根植于硬件配置文件特定的分支之一,而不是HKEY_LOCAL_MACHINE。打开的确切键取决于KeyType的值。
HwProfile:硬件配置文件值,设置如下:
- If Scope is set to DICS_FLAG_CONFIGSPECIFIC, HwProfile specifies the hardware profile of the key that is to be opened.
- If HwProfile is 0, the key for the current hardware profile is opened.
- If Scope is DICS_FLAG_GLOBAL, HwProfile is ignored.
(如果HwProfile为0,打开当前硬件配置文件的键。)
KeyType:要打开的注册表存储键的类型,可以是以下值之一:
DIREG_DEV
Open a hardware key for the device.
DIREG_DRV
Open a software key for the device.
For more information about a device's hardware and software keys, see Registry Trees and Keys for Devices and Drivers.
samDesired:请求的键值项所需的注册表安全访问。
返回值:
如果函数成功,它将返回打开的注册表项的句柄,其中可以存储/检索关于此设备实例的私有配置数据。
如果失败返回INVALID_HANDLE_VALUE。
RegQueryValueEx(E)函数
函数RegQueryValueEx找回一个打开的注册表键值相关联的给定的变量数据或者变量。
LONG RegQueryValueEx(
HKEY hKey, // handle to key 主键句柄
LPCTSTR lpValueName, // value name 子键名称
LPDWORD lpReserved, // reserved 保留
LPDWORD lpType, // type buffer
LPBYTE lpData, // data buffer 存储返回值的缓冲区
LPDWORD lpcbData // size of data buffer存储返回值的缓冲区的大小
);
---------------------
作者:ju_feng
来源:CSDN
原文:https://blog.csdn.net/ju_feng/article/details/6459
版权声明:本文为博主原创文章,转载请附上博文链接!
SetupDi系列函数的更多相关文章
- PHP进程通信基础——shmop 、sem系列函数使用
PHP进程通信基础--shmop .sem系列函数使用 进程通信的原理就是在系统中开辟出一个共享区域,不管是管道也好,还是共享内存,都是这个原理.如果心中有了这个概念,就会很方便去理解代码.由于官网上 ...
- PHP 使用 curl_* 系列函数和 curl_multi_* 系列函数进行多接口调用时的性能对比
在页面中调用的服务较多时,使用并行方式,即使用 curl_multi_* 系列函数耗时要小于 curl_* 系列函数. 测试环境 操作系统:Windows x64 Server:Apache PHP: ...
- 第8章 用户模式下的线程同步(1)_Interlocked系列函数
8.1 原子访问:Interlocked系列函数(Interlock英文为互锁的意思) (1)原子访问的原理 ①原子访问:指的是一线程在访问某个资源的同时,能够保证没有其他线程会在同一时刻访问该资源. ...
- PHP ob系列函数详解
一. 相关函数简介: 1.Flush:刷新缓冲区的内容,输出. 函数格式:flush() 说明:这个函数经常使用,效率很高. 2.ob_start :打开输出缓冲区 函数 ...
- Linux中exec()执行文件系列函数的使用说明
函数原型: 描述: exec()系列函数使用新的进程映像替换当前进程映像. 工作方式没有什么差别, 只是参数传递的方式不同罢了. 说明: 1. 这6个函数可分为两大类: execl( ...
- php Output Control 函数 ob_系列函数详解
<?php /* * 输出缓冲控制 * * flush — 刷新输出缓冲 ob_clean — 清空(擦掉)输出缓冲区 ob_end_clean — 清空(擦除)缓冲区并关闭输出缓冲 ob_en ...
- 从简单需求到OLAP的RANK系列函数
同事问了一个非常简单的问题,怎么取出每个partition里面另外一个列的最小值? create table t1 (int c1, int c2); 假如按照c2分区,0-10,10-20,20 ...
- PHP 载入图像 imagecreatefrom_gif_jpeg_png 系列函数
imagecreatefrom 系列函数用于从文件或 URL 载入一幅图像. 载入图像 imagecreatefrom 系列函数用于从文件或 URL 载入一幅图像,成功返回图像资源,失败则返回一个空字 ...
- PHP中ob系列函数整理
ob,输出缓冲区,是output buffering的简称,而不是output cache.ob用对了,是能对速度有一定的帮助,但是盲目的加上ob函数,只会增加CPU额外的负担. 下面我说说ob的基本 ...
随机推荐
- UF_LAYOUT 布局相关
Open C uc6460uc6462uc6463uc6464 根据视图名称旋转视图,在布局中替换视图uc6466uc6467uc6468uc6469uc6470uc6471uc6472uc6473
- 【UG二次开发】获取对象类型 UF_OBJ_ask_type_and_subtype
代码: int type=0, subtype=0; UF_OBJ_ask_type_and_subtype(objTag, &type, &subtype);
- 【VBA】字符串处理
InStr 函数:查找字符串 1 Sub InStr函数() 2 Dim strTemp As String 3 strTemp = "=AAA=BBB=C" 4 Debug.Pr ...
- Linkerd 2.10(Step by Step)—多集群通信
Linkerd 2.10 系列 快速上手 Linkerd v2.10 Service Mesh(服务网格) 腾讯云 K8S 集群实战 Service Mesh-Linkerd2 & Traef ...
- SqlServer中offset..fetch 的使用问题
好久没更新了,最近忙的很,也生病了,重感冒,555~~~ 早上抽的一丝空闲,来讲讲SqlServer中的分页问题.其实用过了多种数据库,分页这问题已经是老生常谈的问题了.不管是开发什么类型的网站,只要 ...
- OO unit3 summary
Unit3 JML(Java Modeling Language) 是用于对 Java 程序进行规格化设计的一种表示语言,它对于方法内部具体是如何实现的并无要求,只是对方法的接口以及行为进行限制, ...
- STP协议与MSTP协议
STP协议与MSTP协议 目录 一.STP概述 1.1.交换网络环路的产生 1.2.STP简介 二.生成树算法 2.1.生成树算法的步骤 2.2.网桥 ID 2.3.选择根端口 2.4.选择指定端口 ...
- hdu1232 并查集总结
前言 在一些有N个元素的集合应用问题中,我们通常是在开始时让每个元素构成一个单元素的集合,然后按一定顺序将属于同一组的元素所在的集合合并,其间要反复查找一个元素在哪个集合中. 这一类问题其特点是看似并 ...
- hive学习笔记之四:分区表
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
- Linux中curl的用法
一.简介:在Linux中curl是一个利用URL规则在命令行下工作的文件传输工具,是一款强大的http命令行工具.支持文件的上传和下载,是综合传输工具. 二.语法:curl [option] [url ...