Results 1 to 5 of 5

Thread: Convert C++ dll function declaration to VB *RESOLVED*

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Simon Caiger's Avatar
    Join Date
    Aug 2000
    Location
    Rugby, England
    Posts
    377

    Convert C++ dll function declaration to VB *RESOLVED*

    Hi,
    I have a C++ dll which has the following function prototype declared in it.

    VB Code:
    1. Short Int Send_RS232_Command(unsigned char, unsigned char *const, unsigned char, unsigned char *const, long)

    I am trying to use this dll from VB.
    Code I have so far is.

    VB Code:
    1. Option Explicit
    2. Option Base 0
    3.  
    4. Private Declare Function Send_RS232_Command Lib "RS232V2.dll" Alias "?Send_RS232_Command@@YAFEQAEE0J@Z" _
    5.                         (ByVal bBoardAddress As Byte, ByRef bTxDataArray As Byte, _
    6.                         ByVal bTxDataLength As Byte, ByRef bRxDataArray As Byte, ByVal lRxDataLength As Long) As Integer
    7.  
    8. Private Sub cmdSend_Click()
    9.  
    10.     Dim iRet As Integer
    11.     Dim bBoardAddress As Byte
    12.     Dim bTxDataArray(10) As Byte
    13.     Dim bTxDataLength As Byte
    14.     Dim bRxDataArray(10) As Byte
    15.     Dim lRxDataLength As Long
    16.    
    17.     bBoardAddress = 1
    18.     bTxDataArray(0) = 0
    19.     bTxDataArray(1) = 1
    20.     bTxDataArray(2) = 2
    21.     bTxDataArray(3) = 3
    22.     bTxDataArray(4) = 4
    23.     bTxDataLength = 5
    24.    
    25.     iRet = Send_RS232_Command(bBoardAddress, bTxDataArray(0), bTxDataLength, bRxDataArray(0), lRxDataLength)
    26.  
    27. End Sub

    I get the error "Bad DLL Calling Convention".
    Is this because I have incorrectly declared the function?
    Last edited by Simon Caiger; May 4th, 2004 at 07:59 AM.
    Simon Caiger

    Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width