If you want to pass a user defined record between COM objects, you can use
the pair of functions shown below to convert the record to/from OleVariant.
OleVariant can be passed between COM objects.
function MyRecordToVar(Value: TMyRecord): OleVariant;
var
P: Pointer;
V: Variant;
begin
V := VarArrayCreate([0, Sizeof(TMyRecord) - 1], varByte);
P := VarArrayLock(V);
try
Move(Value, P^, Sizeof(TMyRecord));
finally
VarArrayUnlock(V);
end;
Result := V;
end;
function VarToMyRecord(Value: OleVariant): TMyRecord;
var
P: Pointer;
begin
P := VarArrayLock(Value);
try
Move(P^, Result, Sizeof(TMyRecord));
finally
VarArrayUnlock(Value);
end;
end;
Regards,
Tom Munro Glass
> Hi
> Can any one tell me how to pass a user defined datatype from a
> function in a COM object? Source code will be a lot helpful.
> Regds
> Ebi
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"