标题:USB CreateFile()函数使用问题
只看楼主
chen3bing
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:507
专家分:104
注 册:2008-11-12
结帖率:91.22%
 问题点数:0 回复次数:0 
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编辑过]

搜索更多相关主题的帖子: ByVal Long kernel32 USB 函数 
2020-03-07 18:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-499623-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.061653 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved