I need to call a function in an unmanaged .dll written in C lang from vb.net. The function declaration looks like this
LONG _stdcall ReadInfo(char *reply);
Now the behavior of this function is that it copies some data in argument "reply" and returns a numeric value which signals its pass/fail status. How do i pass it a string object so that it can copy data. Following is how i access this function.
Dim str as String obj.ReadDeviceInfo(str)
and the library is accessed this way...
Public Declare Auto Function LoadLibrary Lib "kernel32" (ByVal libFilePath As String) As Integer
Public Declare Function GetProcAddress Lib "kernel32" (ByVal ModuleHandle As Integer, ByVal ProcName As String) As Integer
Public Declare Function FreeLibrary Lib "kernel32" (ByVal ModuleHandle As Integer) As Integer
Public Function ReadDeviceInfo(ByRef reply As String) As Integer
Dim MethodPointer As Integer
MethodPointer = GetProcAddress(ModuleHandle, "ReadInfo")
Dim deviceInfo As ReadInfo = Marshal.GetDelegateForFunctionPointer(MethodPointer, GetType(ReadInfo))
Return deviceInfo.DynamicInvoke(reply)
End Function
When the call completes, returned status is absolutely fine but there is nothing in string "str". What is it that i am missing. I'm not sure about the string object that i am passing as argument. Any thoughts...