인터페이스에 오브젝트 얻기
function GetImplementingObject(const I: IInterface): TObject;
const
AddByte = $04244483;
AddLong = $04244481;
type
PAdjustSelfThunk = ^TAdjustSelfThunk;
TAdjustSelfThunk = packed record
case AddInstruction: longint of
AddByte : (AdjustmentByte: shortint);
AddLong : (AdjustmentLong: longint);
end;
PInterfaceMT = ^TInterfaceMT;
TInterfaceMT = packed record
QueryInterfaceThunk: PAdjustSelfThunk;
end;
TInterfaceRef = ^PInterfaceMT;
var
QueryInterfaceThunk: PAdjustSelfThunk;
begin
Result := Pointer(I);
if Assigned(Result) then
try
QueryInterfaceThunk := TInterfaceRef(I)^. QueryInterfaceThunk;
case QueryInterfaceThunk.AddInstruction of
AddByte: Inc(PChar(Result), QueryInterfaceThunk.AdjustmentByte);
AddLong: Inc(PChar(Result), QueryInterfaceThunk.AdjustmentLong);
else
Result := nil;
end;
except
Result := nil;
end;
end;
'Delphi > 문법' 카테고리의 다른 글
델파이 포인터 사용 팁 (0) | 2024.07.04 |
---|---|
간단한 상속(succession) / 인터페이스(interface) (0) | 2024.06.20 |
델파이의 String 변수 팁 (0) | 2024.05.24 |
for TCollectionItem (0) | 2024.05.11 |
ShortString, LongString, WideString 정적배열, 동적배열 (0) | 2024.05.06 |
댓글