SetupDiGetClassDevs SetupDiEnumDeviceInfo SetupDiGetDeviceRegistryProperty 枚举设备手机
来源:互联网 发布:王勇java 编辑:程序博客网 时间:2024/06/06 00:23
1函数定义编辑
2参数说明编辑
3返回值编辑
4说明编辑
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系列函数进行设备信息的管理(三)
(2012-08-08 13:56:34)usb
分类: 应用程序与硬件设备WINSETUPAPI BOOL WINAPI
SetupDiGetDeviceRegistry
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
);
SetupDiGetDeviceRegistry
参数说明:
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 flag Corresponding DEVICE_CAPABILITIES structure member CM_DEVCAP_LOCKSUPPORTEDLockSupportedCM_DEVCAP_EJECTSUPPORTEDEjectSupportedCM_DEVCAP_REMOVABLERemovableCM_DEVCAP_DOCKDEVICEDockDeviceCM_DEVCAP_UNIQUEIDUniqueIDCM_DEVCAP_SILENTINSTALLSilentInstallCM_DEVCAP_RAWDEVICEOKRawDeviceOKCM_DEVCAP_SURPRISEREMOVALOKSurpriseRemovalOKCM_DEVCAP_HARDWAREDISABLEDHardwareDisabledCM_DEVCAP_NONDYNAMICNonDynamic- 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 incfgmgr32.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 thePropertyBuffer buffer that is required to hold the data for the requested property. This parameter is optional and can be NULL.
Return Value
SetupDiGetDeviceRegistry
函数更改
/*
函数说明: DeviceCheck
参数 pOut_Type 代表手机的品牌类型
参数 pOut_mode 代表启动模式 fastboot(刷机模式) 还有一个正常模式
返回值: 1代表已安装驱动 2代表未安装驱动
*/
BOOL CDriver::DeviceCheck(int *pOut_Type, int *pOut_mode)
{
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
DWORD i;
BOOL re = FALSE;
//获取系统设备信息集合
hDevInfo = SetupDiGetClassDevsA(NULL, "USB", 0, DIGCF_PRESENT | DIGCF_ALLCLASSES );
if (hDevInfo == INVALID_HANDLE_VALUE)
{
return 1;
}
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i=0; SetupDiEnumDeviceInfo(hDevInfo,i,&DeviceInfoData);i++) //枚举出集合中的每一个设备
{
DWORD DataT;
char* buffer = NULL;
DWORD buffersize = 0;
//SPDRP_COMPATIBLEIDS 兼容ID
//SPDRP_HARDWAREID硬件ID
while (!SetupDiGetDeviceRegistryPropertyA( hDevInfo, &DeviceInfoData, SPDRP_COMPATIBLEIDS, &DataT, (PBYTE)buffer, buffersize, &buffersize))
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)//第一次应该是失败的。然后分配空间
{
if (buffer) LocalFree(buffer);
buffer = (char*)LocalAlloc(LPTR,buffersize);
}
else
break;
}
int PhoneType=0;
BOOL Be= FALSE;
//检测硬件ID
if (buffer!=NULL)
{
CStringA sHaraid = buffer;
sHaraid.MakeUpper();
//if( sHaraid.Find( "&MI_01") != -1)//是不是一个正常模式下的手机usb设备?
{
*pOut_mode = 1;
if (sHaraid.Find("CLASS_FF&SUBCLASS_42&PROT")!=-1)//相等
{
CStringA guid111;
buffer =NULL;
buffersize=0;
while (!SetupDiGetDeviceRegistryPropertyA( hDevInfo, &DeviceInfoData, SPDRP_HARDWAREID, &DataT, (PBYTE)buffer, buffersize, &buffersize))
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
if (buffer) LocalFree(buffer);
buffer = (char*)LocalAlloc(LPTR,buffersize);
}
else
break;
}
g_HardID = buffer;
PhoneType=1;
*pOut_Type = PhoneType;
Be = TRUE;
//AfxMessageBox(L"发现手机");
}
}
}
if (buffer) LocalFree(buffer);
//找到手机了,检测是否有驱动
if (Be)
{
//检测硬件ID
CStringA guid, ser;
buffer =NULL;
buffersize=0;
while (!SetupDiGetDeviceRegistryProperty( hDevInfo, &DeviceInfoData, SPDRP_CLASSGUID, &DataT, (PBYTE)buffer, buffersize, &buffersize))
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
if (buffer) LocalFree(buffer);
buffer = (char*)LocalAlloc(LPTR,buffersize);
}
else
break;
}
guid = buffer;//获得硬件ID
if (buffer) LocalFree(buffer);
//检测是否有驱动
buffer =NULL;
buffersize=0;
while (!SetupDiGetDeviceRegistryProperty( hDevInfo, &DeviceInfoData, SPDRP_SERVICE, &DataT, (PBYTE)buffer, buffersize, &buffersize))
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
if (buffer) LocalFree(buffer);
buffer = (char*)LocalAlloc(LPTR,buffersize);
}
else
break;
}
ser = buffer; //获得驱动
if (buffer) LocalFree(buffer);
//判断是否有硬件ID和驱动
if (!guid.IsEmpty() && !ser.IsEmpty())
{
re = TRUE; //有驱动和硬件ID返回True
return re;
}
else
{
re = FALSE; //没有驱动
return re;
}
}
else
re =FALSE;
}
return re;
}
- SetupDiGetClassDevs SetupDiEnumDeviceInfo SetupDiGetDeviceRegistryProperty 枚举设备手机
- 用SetupDiGetClassDevs枚举设备
- 用SetupDiGetClassDevs枚举设备
- 用SetupDiGetClassDevs枚举设备
- 关于SetupDiEnumDeviceInfo枚举设备返回false问题的解决办法
- 关于SetupDiEnumDeviceInfo枚举设备返回 缓冲区无效 解决办法
- SetupDiGetClassDevs
- SetupDiGetClassDevs
- 介绍一个梅举设备信息的DDK函数:SetupDiGetClassDevs
- 设备枚举
- 设备枚举
- SetupDiGetClassDevs介绍
- SetupDiGetClassDevs-使用SetupDi系列函数进行设备信息的管理
- 枚举设备管理器设备
- SetupDiGetDeviceRegistryProperty(,,SPDRP_xxx,,,)的结果
- Pci设备驱动:设备枚举
- USB设备枚举
- PCI设备操作--枚举
- Linux下的权限 chomd
- 路径问题 解决 ${pageContext.request.contextPath} <%=request.getContextPath()%>
- 阿里云 Cent OS 6.3版本自动挂载交换分区失败原因
- gucci outlet stores-208633
- iOS 远程推送参考资料及自己遇到的问题
- SetupDiGetClassDevs SetupDiEnumDeviceInfo SetupDiGetDeviceRegistryProperty 枚举设备手机
- 新手有用的20个命令
- Saving HDU
- servlet的url处理
- Andorid学习 View.post
- 基于MPLAB X IDE配置位设置讲解
- maven打包__自留
- mysql查询的优化
- 谈游戏程序员如何适应需求变更