Tutorial-supports determine if the interface (Instance) is supported

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.