Hi all,
I have a routine that has to check if two variants, v1 and v2, are holding
interfaces to the same underlying object. I've tried the following approaches
with the following results (assumption is that they do indeed point to the same
underlying object:
(1)
result := v1 = v2; - runtime cast error
(2)
var
u1, u2 : IUnknown;
begin
u1 := v1;
u2 := v2;
result := u1 = u2; - u1 and u2 have different addresses
(3)
<<cast to IUnknown same as 2>>
result := @(Pointer(u1)^) = @(Pointer(u2)^) - u1 and u2 are pointing to
different positions in the same object, eg u1 is a TInterfacedObject(X) as
IUnknown and u2 is a TMyObject(X) as IUnknown. The interesting thing here is
that the tool-tip given in the IDE when holding the mouse over each variable
reports X as the same address - ie the same underlying object! I can't work out
how to get that address in code though.
Anybody come accross this before?
cheers,
Phil.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz