Results 1 to 4 of 4

Thread: calling dll written in C

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Hello,
    I have an issue calling a dll written in C. The function I require expects a string parameter and passes another string back:

    char * Plc_genpass(char *);


    however when I call the function from VB it crashes my application:


    Declare Function Plc_genpass Lib "u4ntpgen.dll" ( _
    ByVal ls_string As String) As String


    Can anyone point me in the right direction?


    Thnaks

    Tony.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Thanks FantCool,
    I had the C code modified, and set the function prototype in VB to your suggestion. This again caused a crash.
    I then initialised the return string to 60 spaces in case C had an issue with an uninitialised string. Same result, crash.

    I am presuming the return string is contained in ret_string, and this will be found at the address located by the returned long, is this right?


    Thanks again.

    Tony.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Fant,
    it returns an error reading a particular address then allows me to stat VC++ to debug. The information presented in VC++ is meaningless to me.

    Your function prototype returning the long, can you explain why this was not set up as a sub, since ret_string's address would be known to VB. i.e.

    Declare sub Plc_genpass Lib "u4ntpgen.dll" ( _
    ByVal ls_string As String, ByRef ls_result As String)

    Thanks

    Tony.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254
    Ok Fant,
    I will relook at the dll, thanks for the help.

    much appreciated.

    Tony,

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