How to call DLL function returing string from Excel VBA?

1.1k views Asked by At

I have a compiled DLL coded in C that exports this function:

__stdcall const char *GetVersion() {
    return "1.0.2";
}

I'm trying to call that function from Excel VBA. I've declared it as follows:

Private Declare PtrSafe Function GetVersion Lib "example64.dll" () As String

But when I try to call it:

Debug.Print(GetVersion())

Excel crashes.

I have several other functions working fine that return numbers and such. It's just this one that returns a constant string that is giving me fits. How do I get this to work?

Thanks!

0

There are 0 answers