| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2331 人关注过本帖
标题:请教高手:VB dll 调用约定错误!!
只看楼主 加入收藏
ljob2006
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-5-14
收藏
 问题点数:0 回复次数:3 
请教高手:VB dll 调用约定错误!!
各位高手,我的VB调用DLL,在运行时出现了 dll 调用约定错误! 程序如下,请各位大虾帮忙解决一下!!感恩。。

VB程序:
Option Explicit

'USB User Interface
Public Declare Function Read_USB Lib "DS5000USB_UI.dll" (ByVal mType As Long, ByVal wLength As Long, pBuffer As Any) As Boolean
Public Declare Function Write_USB Lib "DS5000USB_UI.dll" (ByVal cChar As Long) As Boolean

Global Const USB_READ_CMD_REDAY = 0
Global Const USB_READ_CMD_DATA = 1
Global Const ARRAYSIZE = 1024              ' Size of read buffer
Global DSO_IOInitOK As Boolean
Global USB_TimeOutTimer As Long                'USB?????á???±??


Sub USB_Init()
' ========================================================================
'
' INITIALIZATION SECTION
'
' ========================================================================

    ' The application brings the oscilloscope online using ildev. A
    ' device handle, Dev, is returned and is used in all subsequent
    ' calls to the device.
    Dim retcode As Boolean
    Dim ValueStr As String * ARRAYSIZE
    Dim buf(255) As Byte
    ' The application reads the ASCII string from the oscilloscope
    ' into the ValueStr variable.
    retcode = Read_USB(USB_READ_CMD_REDAY, 1, buf(0))
   
    If retcode = False Then
        MsgBox "Cann't Connect to USB Device", 48, "USB Init"
        DSO_IOInitOK = False
    Else
        DSO_IOInitOK = True
    End If
   
End Sub
Sub SendToUSB(cmd As String)
    Dim retcode As Boolean
    Dim buf As String
    Dim temp As Long
    Dim i As Integer
   
    buf = cmd + Chr$(13)

    ' The application writes the text in ScopeCommand to the
    ' oscilloscope.
    For i = 1 To Len(cmd) + 1
        temp = Asc(buf)
        buf = Right(buf, Len(cmd) + 1 - i)
        retcode = Write_USB(temp)
        If retcode = False Then
                MsgBox "Cann't Connect to USB Device", 48, "USB Send Message"
                Exit For
        End If
    Next i

End Sub
Public Function ReadUSB() As String

    Dim retcode As Boolean
    Dim tmpStr As String
    Dim buffer(256) As Byte
    Dim i, size As Long
    ' The application reads the ASCII string from the oscilloscope
    ' into the ValueStr variable.
    USB_TimeOutTimer = 0
    buffer(0) = 0
    While (buffer(0) = 0 And USB_TimeOutTimer < 20)
        retcode = Read_USB(USB_READ_CMD_REDAY, 1, buffer(0))
        If retcode = False Then
            MsgBox "Can't Connect to USB Device", 48, "USB Read Message"
            ReadUSB = ""
            Exit Function
        End If
        DoEvents
    Wend
    If USB_TimeOutTimer > 19 Then
        MsgBox "Read USB time out", 48, "USB Read Message"
        tmpStr = ""
    Else
        size = buffer(0)
        retcode = Read_USB(USB_READ_CMD_DATA, size, buffer(0))
        If retcode = False Then
            MsgBox "Cann't Connect to USB Device", 48, "USB Read Message"
            ReadUSB = ""
            Exit Function
        End If
        tmpStr = ""
        For i = 0 To size - 1
            If (buffer(i) = 10) Then
                Exit For
            End If
            tmpStr = tmpStr + Chr(buffer(i))
        Next i
    End If
    ReadUSB = tmpStr
   
End Function



DLL函数定义:

附件(DLL头文件)

DS5000USB_UI.zip (1.86 KB) DLL头文件

搜索更多相关主题的帖子: dll USB CMD ByVal 
2008-02-29 09:13
ljob2006
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2006-5-14
收藏
得分:0 
最具有挑战性的,VB调用DLL编程。。走过路过不要错过!!
各位大虾,怎么不回信。。。。。
等的好辛苦!!
2008-02-29 14:22
lanshanlhy
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2006-4-16
收藏
得分:0 
好象需要加DLL文件的路径

永远以今天为荣!
2008-03-04 18:59
lanshanlhy
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2006-4-16
收藏
得分:0 
没做过!不知道脱壳后是否能够实现 试试

永远以今天为荣!
2008-03-04 19:07
快速回复:请教高手:VB dll 调用约定错误!!
数据加载中...
 
   



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

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