USB CreateFile()函数使用问题
我正在看一本VB6 USB编程的书,《8051单片机USB接口Visual Basic程序设计》看到第12章,取得设备的标示代号:
原程序为:
Public Declare Function CreateFile _
Lib "kernel32" _
Alias "CreateFileA" _
(ByVal lpFileName As String, _
ByVal dwDesiredAccess As Long, _
ByVal dwShareMode As Long, _
ByRef lpSecurityAttributes As Long, _
ByVal dwCreationDisposition As Long, _
ByVal dwFlagsAndAttributes As Long, _
ByVal hTemplateFile As Long) _
As Long
执行效果如下:
提示内存位置访问无效。
后来下载了一个例程,
Dim Security As SECURITY_ATTRIBUTES
Public Declare Function CreateFile _
Lib "kernel32" _
Alias "CreateFileA" _
(ByVal lpFileName As String, _
ByVal dwDesiredAccess As Long, _
ByVal dwShareMode As Long, _
ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, _
ByVal dwCreationDisposition As Long, _
ByVal dwFlagsAndAttributes As Long, _
ByVal hTemplateFile As Long) _
As Long
执行效果如图:
为什么会这样呢?请高手指教,谢谢!
[此贴子已经被作者于2020-3-7 18:58编辑过]