注册 登录
编程论坛 VB6论坛

USB CreateFile()函数使用问题

chen3bing 发布于 2020-03-07 18:50, 1566 次点击
我正在看一本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编辑过]

0 回复
1