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系列函数的更多相关文章

  1. PHP进程通信基础——shmop 、sem系列函数使用

    PHP进程通信基础--shmop .sem系列函数使用 进程通信的原理就是在系统中开辟出一个共享区域,不管是管道也好,还是共享内存,都是这个原理.如果心中有了这个概念,就会很方便去理解代码.由于官网上 ...

  2. PHP 使用 curl_* 系列函数和 curl_multi_* 系列函数进行多接口调用时的性能对比

    在页面中调用的服务较多时,使用并行方式,即使用 curl_multi_* 系列函数耗时要小于 curl_* 系列函数. 测试环境 操作系统:Windows x64 Server:Apache PHP: ...

  3. 第8章 用户模式下的线程同步(1)_Interlocked系列函数

    8.1 原子访问:Interlocked系列函数(Interlock英文为互锁的意思) (1)原子访问的原理 ①原子访问:指的是一线程在访问某个资源的同时,能够保证没有其他线程会在同一时刻访问该资源. ...

  4. PHP ob系列函数详解

    一. 相关函数简介:    1.Flush:刷新缓冲区的内容,输出.    函数格式:flush()    说明:这个函数经常使用,效率很高.    2.ob_start :打开输出缓冲区    函数 ...

  5. Linux中exec()执行文件系列函数的使用说明

    函数原型: 描述:    exec()系列函数使用新的进程映像替换当前进程映像.    工作方式没有什么差别, 只是参数传递的方式不同罢了. 说明:    1. 这6个函数可分为两大类: execl( ...

  6. php Output Control 函数 ob_系列函数详解

    <?php /* * 输出缓冲控制 * * flush — 刷新输出缓冲 ob_clean — 清空(擦掉)输出缓冲区 ob_end_clean — 清空(擦除)缓冲区并关闭输出缓冲 ob_en ...

  7. 从简单需求到OLAP的RANK系列函数

    同事问了一个非常简单的问题,怎么取出每个partition里面另外一个列的最小值? create table t1 (int c1, int c2);   假如按照c2分区,0-10,10-20,20 ...

  8. PHP 载入图像 imagecreatefrom_gif_jpeg_png 系列函数

    imagecreatefrom 系列函数用于从文件或 URL 载入一幅图像. 载入图像 imagecreatefrom 系列函数用于从文件或 URL 载入一幅图像,成功返回图像资源,失败则返回一个空字 ...

  9. PHP中ob系列函数整理

    ob,输出缓冲区,是output buffering的简称,而不是output cache.ob用对了,是能对速度有一定的帮助,但是盲目的加上ob函数,只会增加CPU额外的负担. 下面我说说ob的基本 ...

随机推荐

  1. Redis 入门权威指北

    前言 看看业务遇到了什么问题? 我们要从互联网架构的演变之路开始说起Redis的前世今生. 在我们小的时候,网络世界好像就是只有通过大屁股台式机才能进入一样,彼时的手机只是用来打打电话,发发短信,网上 ...

  2. SpringBoot数据访问(一) SpringBoot整合Mybatis

    前言 SpringData是Spring提供的一个用于简化数据库访问.支持云服务的开源框架.它是一个伞形项目,包含了大量关系型数据库及非关系型数据库的数据访问解决方案,其设计目的是为了使我们可以快速且 ...

  3. 【NX二次开发】Block UI 线条颜色/线型/宽度

    属性说明 常规         类型 描述     BlockID     String 控件ID     Enable     Logical 是否可操作     Group     Logical ...

  4. 《四大点,搞懂Redis到底快在哪里?》

    一.开发语言 二.纯内存访问 三.单线程 四.非阻塞多路I/O复用机制 前言 Redis是一种基于键值对(Key-Value)的NoSQL数据库 ,Redis的Value可以由String,hash, ...

  5. 【题解】Luogu P1011 车站

    题目描述 火车从始发站(称为第1站)开出,在始发站上车的人数为a,然后到达第2站,在第2站有人上.下车,但上.下车的人数相同,因此在第2站开出时(即在到达第3站之前)车上的人数保持为a人.从第3站起( ...

  6. 【模板】 RMQ求区间最值

    RMQ RMQ简单来说就是求区间的最大值(最小值) 核心算法:动态规划 RMQ(以下以求最大值为例) F[i,j]表示 从 i 开始 到i+2j -1这个区间中的最大值 状态转移方程 F[i,j]=m ...

  7. 基于ABP落地领域驱动设计-01.全景图

    什么是领域驱动设计? 领域驱动设计(简称:DDD)是一种针对复杂需求的软件开发方法.将软件实现与不断发展的模型联系起来,专注于核心领域逻辑,而不是基础设施细节.DDD适用于复杂领域和大规模应用,而不是 ...

  8. 我的新书《C++服务器开发精髓》终于出版啦

    一.千呼万唤始出来 亲爱的各位读者,我的新书<C++ 服务器开发精髓>终于终于终于与大家见面了,图书如下: 图书的封面设计很精美,当然内容一定不负众望.因出版社老师要求提供一张照片放到封面 ...

  9. Kubernetes之Ingress

    在Service篇里面介绍了像集群外部的客户端公开服务的两种方法,还有另一种方法---创建Ingress资源. 定义Ingress (名词)-进入或进入的行为;进入的权利;进入的手段或地点;入口. 接 ...

  10. Docker单机网络上

    前言 Docker系列文章: 此篇是Docker系列的第六篇,大家一定要按照我做的Demo都手敲一遍,印象会更加深刻的,加油! 为什么要学习Docker Docker基本概念 Docker镜像基本原理 ...