I've tried several variations of the code below with returning HRESULT (which is the preferable COM standard) or returning BSTR. I've tried other datatypes as well. I usually get a "missing implementation of interface method" compile error, but when I used a return type of WideString, there was a runtime AccessViolationException on the result:=RetVal;
instruction.
I'm using C# on the client side:
var msg = delphi.GetMessage("My Message");
Here is mi RIDL:
HRESULT _stdcall GetMessage([in] BSTR msg, [out, retval] BSTR* RetVal);
Here is my implementation:
function TDelphiCom.GetMessage(msg:WideString; out RetVal:WideString):HRESULT;
var
tempString: string;
begin
tempString:=msg;
RetVal:=WideString(tempString);
end;
What is the correct way to pass strings in/out of a Delphi COM server?