none
Interfacing VB6 with a DLL written in C++ RRS feed

  • Question

  • Hello All,

    I am trying to interface my VB6 with a DLL written in C++. The DLL was actually written by someone else here at the company who I do not have access to at the moment.

    The function that I need to call is declared as follows:

    //int a35dbd7v2(int service, int AC0_CryptoKeyTable, unsigned char* seed, unsigned char* key);
    VBDLLFUNC(int) MDNSa35dbd7v2(int service, int AC0_CryptoKeyTable, unsigned char* seed, unsigned char* key) {
    return (a35dbd7v2(service, AC0_CryptoKeyTable, seed, key));
    }

    Where #define VBDLLFUNC(TypeName) DLLEXPORT TypeName __stdcall

    The question that I have is this, what would the declare look like in VB6?

    What is the equivalent to unsigned char*?

    Please advise

    Thank you

    Gary

    Monday, December 9, 2019 7:02 PM

All replies

  • Hello All,

    I am trying to interface my VB6 with a DLL written in C++. The DLL was actually written by someone else here at the company who I do not have access to at the moment.

    The function that I need to call is declared as follows:

    //int a35dbd7v2(int service, int AC0_CryptoKeyTable, unsigned char* seed, unsigned char* key);
    VBDLLFUNC(int) MDNSa35dbd7v2(int service, int AC0_CryptoKeyTable, unsigned char* seed, unsigned char* key) {
    return (a35dbd7v2(service, AC0_CryptoKeyTable, seed, key));
    }

    Where #define VBDLLFUNC(TypeName) DLLEXPORT TypeName __stdcall

    The question that I have is this, what would the declare look like in VB6?

    What is the equivalent to unsigned char*?


    First, you need to determine if the exported function from the C++ dll has been declared using C linkage or C++ linkage.  That influences how the function name is decorated (i.e., mangled).

    But you are really asking a VB6 question and so I suggest you post your question at http://www.vbforums.com/forumdisplay.php?1-Visual-Basic-6-and-Earlier

    The Dumpbin utility with the /EXPORTS will help you determine the exported function name from the C++ dll.


    • Edited by RLWA32 Monday, December 9, 2019 7:48 PM
    Monday, December 9, 2019 7:45 PM
  • It's impossible for me to imagine that there is still new development going on in VB6.  That product is now 22 years old.  Do you do your development on a Windows 95 system?  It's from the same era.

    Do you have a 32-bit version of the DLL?  Remember that VB6 can't talk to 64-bit binaries.  "unsigned char *" is just a way of saying "buffer". You may be able to pass that data in a string.  Something like this should work:

    Declare Function a35dbd7v2 lib "xxxxx.lib" (
        Service as Integer,
        AC0_CryptoKeyTable as Integer,
        ByVal Seed$,
        ByVal Key$
    )

    Alternatively, you can use "ByVal Seed as Long" and use VarPtr to get a pointer to a byte array.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Monday, December 9, 2019 7:49 PM