在使用Com组件的程序中经常需要将Variant/OleVariant类型转换为特定的接口类型。例如在微软的安全组件(CAPICom)的ICertificates 接口中,
需要将Item返回的OleVariant类型转换为ICertificate接口。
ICertificates = interface(IDispatch)
['{68646716-BDA0-4046-AB82-4444BC93B84A}']
function Get_Item(Index: Integer): OleVariant; safecall;
function Get_Count: Integer; safecall;
function Get__NewEnum: IUnknown; safecall;
property Item[Index: Integer]: OleVariant read Get_Item; default;
property Count: Integer read Get_Count;
property _NewEnum: IUnknown read Get__NewEnum;