社区
C++ 语言
帖子详情
SetupDiGetDeviceInterfaceDetail 在生成dll中提示无法解析的外部符号
fisher
2012-03-20 04:13:32
SetupDiGetDeviceInterfaceDetail 在生成dll中提示无法解析的外部符号
...全文
249
3
打赏
收藏
SetupDiGetDeviceInterfaceDetail 在生成dll中提示无法解析的外部符号
SetupDiGetDeviceInterfaceDetail 在生成dll中提示无法解析的外部符号
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
fisher
2012-03-20
打赏
举报
回复
谢谢,当刚到呵呵。分分给你俩。还有个问题通过接口打开WDM设备的问题未解决还望指点。
fishion
2012-03-20
打赏
举报
回复
缺少头文件和库文件吧
Jim_King_2000
2012-03-20
打赏
举报
回复
加上Setupapi.lib。
vb.net2003编写的HID测试程序,根据网上的VB6修改,功能已经全部实现
vb.net2003编写的HID测试程序,根据网上的VB6修改,功能已经全部实现。包括HidD_GetHidGuid,
Setup
Di
GetClassDevs,
Setup
Di
Enum
Device
Interface
s,CreateFile,
Setup
Di
Get
Device
Interface
De
tail
等API函数的声明和调用
枚举USB设备接口(C++源代码)
c++ 实现枚举USB设备接口 涉及函数:
Setup
Di
GetClassDevs
Setup
Di
Enum
Device
Interface
s
Setup
Di
Get
Device
Interface
De
tail
usb communication
利用USB接口进行通信的数据源码MemberIndex = 0 Do 'The cbSize element of the My
Device
Interface
Data structure must be set to 'the structure's size in bytes. The size is 28 bytes. My
Device
Interface
Data.cbSize = LenB(My
Device
Interface
Data) Result =
Setup
Di
Enum
Device
Interface
s _ (
Device
InfoSet, _ 0, _ HidGuid, _ MemberIndex, _ My
Device
Interface
Data) Call
Di
splayResultOfAPICall("
Setup
Di
Enum
Device
Interface
s") If Result = 0 Then Last
Device
= True 'If a
device
exists,
di
splay the information returned. If Result <> 0 Then lstResults.Ad
dI
tem "
Device
InfoSet for
device
#" & CStr(MemberIndex) & ": " lstResults.Ad
dI
tem " cbSize = " & CStr(My
Device
Interface
Data.cbSize) lstResults.Ad
dI
tem _ "
Interface
ClassGuid.Data1 = " & Hex$(My
Device
Interface
Data.
Interface
ClassGuid.Data1) lstResults.Ad
dI
tem _ "
Interface
ClassGuid.Data2 = " & Hex$(My
Device
Interface
Data.
Interface
ClassGuid.Data2) lstResults.Ad
dI
tem _ "
Interface
ClassGuid.Data3 = " & Hex$(My
Device
Interface
Data.
Interface
ClassGuid.Data3) lstResults.Ad
dI
tem _ " Flags = " & Hex$(My
Device
Interface
Data.Flags) '****************************************************************************** '
Setup
Di
Get
Device
Interface
De
tail
'Returns: an SP_
DEVICE
_
INTERFACE
_DE
TAIL
_DATA structure 'containing information about a
device
. 'To retrieve the information, call this function twice. 'The first time returns the size of the structure in Needed. 'The second time returns a pointer to the data in
Device
InfoSet. 'Requires: 'A
Device
InfoSet returned by
Setup
Di
GetClassDevs and 'an SP_
DEVICE
_
INTERFACE
_DATA structure returned by
Setup
Di
Enum
Device
Interface
s. '******************************************************************************* My
Device
InfoData.cbSize = Len(My
Device
InfoData) Result =
Setup
Di
Get
Device
Interface
De
tail
_ (
Device
InfoSet, _ My
Device
Interface
Data, _ 0, _ 0, _ Needed, _ 0) De
tail
Data = Needed Call
Di
splayResultOfAPICall("
Setup
Di
Get
Device
Interface
De
tail
") lstResults.Ad
dI
tem " (OK to say too small)" lstResults.Ad
dI
tem " Required buffer size for the data: " & Needed 'Store the structure's size. My
Device
Interface
De
tail
Data.cbSize = _ Len(My
Device
Interface
De
tail
Data) 'Use a byte array to allocate memory for 'the My
Device
Interface
De
tail
Data structure Re
Di
m De
tail
DataBuffer(Needed) 'Store cbSize in the first four bytes of the array. Call RtlMoveMemory _ (De
tail
DataBuffer(0), _ My
Device
Interface
De
tail
Data, _ 4) 'Call
Setup
Di
Get
Device
Interface
De
tail
again. 'This time, pass the address of the first element of De
tail
DataBuffer 'and the returned required buffer size in De
tail
Data. Result =
Setup
Di
Get
Device
Interface
De
tail
_ (
Device
InfoSet, _ My
Device
Interface
Data, _ VarPtr(De
tail
DataBuffer(0)), _ De
tail
Data, _ Needed, _ 0) Call
Di
splayResultOfAPICall(" Result of second call: ") lstResults.Ad
dI
tem " My
Device
Interface
De
tail
Data.cbSize: " & _ CStr(My
Device
Interface
De
tail
Data.cbSize) 'Convert the byte array to a string.
Device
PathName = CStr(De
tail
DataBuffer()) 'Convert to Unicode.
Device
PathName = StrConv(
Device
PathName, vbUnicode) 'Strip cbSize (4 bytes) from the beginning.
Device
PathName = Right$(
Device
PathName, Len(
Device
PathName) - 4) lstResults.Ad
dI
tem "
Device
pathname: " lstResults.Ad
dI
tem " " &
Device
PathName '****************************************************************************** 'CreateFile 'Returns: a handle that enables rea
di
ng and writing to the
device
. 'Requires: 'The
Device
PathName returned by
Setup
Di
Get
Device
Interface
De
tail
. '****************************************************************************** Hid
Device
= CreateFile _ (
Device
PathName, _ GENERIC_READ Or GENERIC_WRITE, _ (FILE_SHARE_READ Or FILE_SHARE_WRITE), _ 0, _ OPEN_EXISTING, _ 0, _ 0) Call
Di
splayResultOfAPICall("CreateFile") lstResults.Ad
dI
tem " Returned handle: " & Hex$(Hid
Device
) & "h" 'Now we can find out if it's the
device
we're looking for. '****************************************************************************** 'HidD_GetAttributes 'Requests information from the
device
. 'Requires: The handle returned by CreateFile. 'Returns: an HIDD_ATTRIBUTES structure containing 'the Vendor ID, Product ID, and Product Version Number. 'Use this information to determine if the detected
device
'is the one we're looking for. '****************************************************************************** 'Set the Size property to the number of bytes in the structure.
Device
Attributes.Size = LenB(
Device
Attributes) Result = HidD_GetAttributes _ (Hid
Device
, _
Device
Attributes) Call
Di
splayResultOfAPICall("HidD_GetAttributes") If Result <> 0 Then lstResults.Ad
dI
tem " HIDD_ATTRIBUTES structure filled without error." Else lstResults.Ad
dI
tem " Error in filling HIDD_ATTRIBUTES structure." End If lstResults.Ad
dI
tem " Structure size: " &
Device
Attributes.Size lstResults.Ad
dI
tem " Vendor ID: " & Hex$(
Device
Attributes.VendorID) lstResults.Ad
dI
tem " Product ID: " & Hex$(
Device
Attributes.ProductID)
获得USB的信息vc++
现在USB设备却很多,因此对USB设备的查找与读写就必不可少了。但是能找到关于USB读写的资料很少。这里使用VC++示范了一些获得USB的信息的方法。 一、枚举USB设备 通过枚举USB控制器->枚举此控制器上的USB HUB->枚举HUB的各个端口->获得设备信息。 枚举控制器: wsprintf(HCName, "\\\\.\\HCD%d", HCNum); hHCDev = CreateFile(HCName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); 计算机上的USB主控制器以HCD1,HCD2等命名。通过控制器名称,使用CCreateFile 打开它。使用
Device
IoControl即可得到其驱动程序名,以及与它连接的HUB的名称。用CCreateFile打开HUB,获得连接信息。再枚举HUB的各个端口即可获得连接的设备信息。 二、枚举HID设备 HID设备是微软定义的标准人机接口规范。比如USB鼠标,USB游戏手柄等。不用查找具体设备的GUID,使用API HidD_GetHidGuid(&guidHID)即可得到GUID。有了GUID通过API
Setup
Di
Enum
Device
Interface
s可获得是否有设备连接。如果此类设备连接通过
Setup
Di
Get
Device
Interface
De
tail
获得它的设备路径信息。使用CCreateFile 打开它,通过HidD_GetAttributes获得其基本属性信息。使用
Device
IoControl可以获得更详细的属性。在本代码
中
如果计算机上插有USB游戏手柄,可获得其信息。但不知道为什么xp下却不能获得USB鼠标的信息。 三 枚举U盘 先用GetDriveType API获得设备的类型,若类型为REMOVABLE(当然有些大容量U盘可能报告为FIXED,那就需要其他方法来确定了),即可能是U盘。用CCreateFile 打开之后,再用IOCTL_STORAGE_QUERY_PROPERTY为参数的
Device
IoControl来获得其属性。 四、结束语 示例工程在winxp+xpDDK+VC6下编译通过。USB设备种类比较多,也比较特殊,不同厂商的硬件不同,控制软件也不尽相同(我想主要是ICTL码不同,也不容易查到)。使得访问USB口的设备不象串口并口那么方便。这个例程只是展示了访问的基本方法。其
中
还有些问题还没有解决,发出来希望大家解决之后能通知我或者发表出来。 参考了USBPort,USBview等代码,一并致谢。
VB.NET2003测试USB HID设备程序
在网上找了好久这样的例子,只找到VB,VC,VC.NET,C#的,就是没有VB.NET的。说明一下,VB.NET于VB有些不同,特别是函数
Setup
Di
Get
Device
Interface
De
tail
的API声明是关键。本人尝试了一个礼拜,又参照了很多其他语言的例子,才试出来,希望对大家有所帮助
C++ 语言
64,654
社区成员
250,484
社区内容
发帖
与我相关
我的任务
C++ 语言
C++ 语言相关问题讨论,技术干货分享,前沿动态等
复制链接
扫一扫
分享
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
请不要发布与C++技术无关的贴子
请不要发布与技术无关的招聘、广告的帖子
请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下
试试用AI创作助手写篇文章吧
+ 用AI写文章