Still having a problem with this, the examples below just returns gibberish. Can anyone see what is wrong?
Code:
simplified version DLL function to return a pchar (for compatibility with VB)
function Readline: Pchar; stdcall;
var s: string;
begin
s := 'hello world';
result := Pchar(s);
end;
Code:
Delphi calling code based on previously posted Delphi way of doing this:
------------------
var
Ret : AnsiString;
P : PChar;
begin
SetLength(Ret, 1024); // assign space
P := PChar(Ret); // make a pointer to the space
P := Readline; // as the function returns a pointer (PChar) this should now be a pointer to the string
MessageBox.Text := Ret; // display the result
end;
Steve [The sane]: Delphi a feersum engin indeed.