Would you mind showing the API function?
@Ulrich_Bogun – sure, happy to:
// This is the external C-API of the C++ DLL:
extern "C" MY_DLL_EXPORT int64_t CallDLLWithMultipleParams(const char* functionName, input_params * inParams, return_value * retVal);
This is the Xojo public function in module MyDLL that actually calls the DLL function:
Public Function XojoCallMyDLLMultipleParams (functionName as CString, ByRef inParam as MyApp.input_values, ByRef retVal as MyApp.return_value) As Int64
Declare Function CallDLLWithMultipleParams Lib "MyClientWinDLL.dll" (functionName as CString, ByRef inParam as MyApp.input_values, ByRef retVal as MyApp.return_value) as Int64
Var retErr as Integer = CallPLMSMultipleParams(functionName, inParam, retVal)
return retErr
End Function
Your structure cannot be right. A structure is a memory block of a fixed size. You are reserving CStrings of Len 0 with your structure. They are 4 Bytes long, so there is only space for the ending 0 Char …
Well, when I measure the actual size of that structure at runtime, the CString fields are in fact 8 bytes (because the Xojo’s IDE only shows the struct size as 32-bit, even though I’m only building a 64-bit app. This is a clear indication that they are in fact 64-bit pointers.
Var returnedValues as MyApp.return_value
Var inParams as MyApp.input_values
// assignment from Xojo String to CString first is REQUIRED
Var st1 as CString = aGuidString
Var st2 as CString = anotherGUIDString
inParams.fPLMSParamString1 = st1
inParams.fPLMSParamString2 = st2
inParams.fPLMSParamCount = 2
Var result as Int64 = MyDLL.XojoCallMyDLLMultipleParams("DLLFunctionName", inParams, returnedValues))
What I’m doing above IS working, and my strings that are way longer than 4 or 8 bytes. The DLL correctly receives and interprets those structure fields as a char * (a pointer to a c-string).