zoukankan      html  css  js  c++  java
  • 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 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 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
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    梯度下降算法实现
    windows10下Anaconda的安装与tensorflow、opencv的安装与环境配置
    在github创建用户
    看完教材不明白的问题
    自我介绍
    HDU 1098(条件满足 数学)
    HDU 1097(m次幂的个位数 规律)
    HDU 1046(最短路径 **)
    HDU 1045(炮台安置 DFS)
    HDU 1034(传递糖果 模拟)
  • 原文地址:https://www.cnblogs.com/jony7/p/10395296.html
Copyright © 2011-2022 走看看