G
Guest
I have a DLL that i'm interfacing with that's in C++. here's the interface
defn:
SendCommand(void *h, char *cmd, char *data, char *respbuffer);
here's the wrapper for the dll call in my C# code:
[DllImport("test.dll", CharSet = CharSet.Ansi, EntryPoint = "SendCommand")]
unsafe public static extern char* SendCommand(void* h,
[MarshalAs(UnmanagedType.LPStr)] string cmd, [MarshalAs(UnmanagedType.LPStr)]
string data, [MarshalAs(UnmanagedType.LPArray)] ref byte[] buffer);
and here's my function call:
//code here...
byte buf = new byte[25];
SendCommand(handle, "cmd string", "data", buf);
i think the cmd parameter is getting messed up when i marshal it as LPStr!!
am i doing something wrong? the reason i say this is i do not get any
response in the response buffer!!!
i could get the same function call working in C++ and i do see the response
in the buffer...can someone please help?
defn:
SendCommand(void *h, char *cmd, char *data, char *respbuffer);
here's the wrapper for the dll call in my C# code:
[DllImport("test.dll", CharSet = CharSet.Ansi, EntryPoint = "SendCommand")]
unsafe public static extern char* SendCommand(void* h,
[MarshalAs(UnmanagedType.LPStr)] string cmd, [MarshalAs(UnmanagedType.LPStr)]
string data, [MarshalAs(UnmanagedType.LPArray)] ref byte[] buffer);
and here's my function call:
//code here...
byte buf = new byte[25];
SendCommand(handle, "cmd string", "data", buf);
i think the cmd parameter is getting messed up when i marshal it as LPStr!!
am i doing something wrong? the reason i say this is i do not get any
response in the response buffer!!!
i could get the same function call working in C++ and i do see the response
in the buffer...can someone please help?