Создать базовый класс, основывающийся на IUnknownDelphi , Технологии , COM и DCOMСоздать базовый класс, основывающийся на IUnknown
Оформил: DeeCo If I want automatic garbage collection with interfaces, I use TInterfacedObject as base class. What should I use, if I don''t want automatic destruction? is there a similar common base class or do I have to implement the IInterface methods myself? I use this one: {== BaseNonRefcountIntfObjU ===========================================} {: This unit provides a base class with a non-reference counted implementation of IUnknown. @author Dr. Peter Below @desc Version 1.0 created 28 Mдrz 2002 Last modified 28 Mдrz 2002 } {======================================================================} unit BaseNonRefcountIntfObjU; interface type {: Derive classes that need a non-reference counted IUNknown implementation from this class. } TNonRefcountInterfacedObject = class(TObject, IUnknown) protected { IUnknown } function QueryInterface(const IID : TGUID; out Obj): HResult; stdcall; function _AddRef: Integer; stdcall; function _Release: Integer; stdcall; end; implementation uses Windows; function TNonRefcountInterfacedObject.QueryInterface(const IID : TGUID; out Obj): HResult; begin if GetInterface(IID, Obj) then Result := S_OK else Result := E_NOINTERFACE end; function TNonRefcountInterfacedObject._AddRef: integer; begin Result := -1 // -1 indicates no reference counting is taking place end; function TNonRefcountInterfacedObject._Release: integer; begin Result := -1 // -1 indicates no reference counting is taking place end; end { BaseNonRefcountIntfObjU }. Статья Создать базовый класс, основывающийся на IUnknown раздела Технологии COM и DCOM может быть полезна для разработчиков на Delphi и FreePascal. Комментарии и вопросыМатериалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта. :: Главная :: COM и DCOM ::
|
||||
©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007 |