EDIT: I\'ve posted a better implementation of this, below. I left this here so the responses would make sense.
I\'ve done numerous searches for the
It is easier to retireve a string using PString:
function DelphiFunction(inputString : PAnsiChar;
var outputStringBuffer : PString;
var errorMsgBuffer : PString)
: WordBool; stdcall; export;
var
s : string;
begin
try
s := inputString;
outputStringBuffer:=PString(AnsiString(s));
Result := true;
except
on e : exception do
begin
s:= 'error';
errorMsgBuffer:=PString(AnsiString(e.Message));
Result := false;
end;
end;
end;
In c# then:
const int stringBufferSize = 1024;
var str = new IntPtr(stringBufferSize);
string loginResult = Marshal.PtrToStringAnsi(str);