1 functionTcommandenabledcontroller.getcommandvisible (ConstAcommandname:string): Boolean;2 var3 I:integer;4 //Defining Interface Recipients5 Ocommandvisibleexecutor:icommandvisibleexecutor;6 begin7Result: =True;8 forI: =0 toFexecutors.count-1 Do9 beginTen //determine if the interface supports One ifSupports (Fexecutors[i], icommandvisibleexecutor, Ocommandvisibleexecutor) Then A begin - //using the interface recipient - if notOcommandvisibleexecutor.commandvisible (Acommandname) Then the begin -Result: =False; - Break ; - End; + End; - End; + End;
The function supports in Delphi is located in the Sysutils unit
Defined as follows:
1 {Interface Support Routines}2 3 functionSupports (ConstInstance:iinterface;ConstIid:tguid; outIntf): Boolean;Overload;4 functionSupports (ConstInstance:tobject;ConstIid:tguid; outIntf): Boolean;Overload;5 functionSupports (ConstInstance:iinterface;ConstIID:TGUID): Boolean;Overload;6 functionSupports (ConstInstance:tobject;ConstIID:TGUID): Boolean;Overload;7 functionSupports (ConstAclass:tclass;ConstIID:TGUID): Boolean;Overload;
The implementation is as follows :
1 {Interface Support Routines}2 3 functionSupports (ConstInstance:iinterface;ConstIid:tguid; outIntf): Boolean;4 begin5Result: = (Instance <>Nil) and(Instance.queryinterface (IID, Intf) =0);6 End;7 8 functionSupports (ConstInstance:tobject;ConstIid:tguid; outIntf): Boolean;9 varTen Lunknown:iunknown; One begin AResult: = (Instance <>Nil) and -(Instance.getinterface (IUnknown, Lunknown) andSupports (Lunknown, IID, Intf))or - instance.getinterface (IID, Intf)); the End; - - functionSupports (ConstInstance:iinterface;Constiid:tguid): Boolean; - var + Temp:iinterface; - begin +Result: =Supports (Instance, IID, Temp); A End; at - functionSupports (ConstInstance:tobject;Constiid:tguid): Boolean; - var - Temp:iinterface; - begin -Result: =Supports (Instance, IID, Temp); in End; - to functionSupports (ConstAclass:tclass;Constiid:tguid): Boolean; + begin -Result: = Aclass.getinterfaceentry (IID) <>Nil; the End;
Tutorial-supports determine if the interface (Instance) is supported