I'm using an dll and have declared some functions that I need to use:
Declare Function API_GetSeg Lib "MLAPI32.dll" (ByVal strSeg As String, ByVal Level As Integer, ByVal Threshold As Integer) As <MarshalAs(UnmanagedType.U1)> Boolean
Declare Function API_GetElm Lib "MLAPI32.dll" (ByVal strSegment As String, ByVal strElement As String, ByRef rData As String) As <MarshalAs(UnmanagedType.U1)> Boolean
The first function works fine (API_GetSeg).
I've got problems with the second function (API_GetElm) that gives the following error:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
API_GetElm, Variable rData is declared with ByRef because the function is going to change this value/return a string.
When I'm running the code with rData declared with ByVal, the error does not appear, but then I don't get my return value.
I think the dll is written in C.
How should I declare the function?