Results 1 to 4 of 4

Thread: DLL calling convention prob

  1. #1
    Guest
    My friend had written a DLL with C from which we are calling some functions in VB. The following is the code we're using but every time it gives us runtime errors - 'DLL Calling Convention Error'..

    Can anyone enlighten us?

    Code:
    Global flagName As String
    
    Public Declare Function getFlagState Lib "edrlib" (ByVal flagName As String) As Long
    
    
    Private Sub Form_Load()
        e = getFlagState(flagName) 'error here
    End Sub

    Even any little pointers?? Is the problem in our DLL - it may be to do with the string data type...

    Cheers!
    Mafro

    [Edited by Mafro on 05-26-2000 at 10:27 AM]

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    it could well be with the string, passing it byval to C++ is right, when you get it in C++ you get a long pointer to a char array, is this what yu were expecting? If not change the dll.

  3. #3
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Don't forget to initialise the string before passing it to the dll.
    eg
    flagName = space(255)
    e = getFlagState(flagName)

  4. #4
    Guest
    The DLL has been tested in C with another program and works fine - my friend that wrote the DLL says he was expecting a long pointer to a char array.. This is the function prototype from the DLL:

    int __declspec(dllexport) __cdecl getFlagState(LPSTR flagName);

    Also, the flagName variable has a value when it is passed to the function, so we don't need to initialise it..

    Would anyone mind having a look at the DLL and the program as it stands??

    Thanks!!

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