AlonsoYSal_FactuGES2/Source/Base/uDataModuleBase.pas
2019-11-18 10:36:42 +00:00

52 lines
1004 B
ObjectPascal

unit uDataModuleBase;
interface
uses
Classes;
type
TDataModuleBase = class(TDataModule)
private
FRefCount: Integer;
protected
function QueryInterface(const IID: TGUID; out Obj): HResult; override; stdcall;
function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall;
public
property RefCount: integer read fRefCount write fRefCount;
end;
implementation
{$R *.DFM}
// Set an implicit refcount so that refcounting
// during construction won't destroy the object.
function TDataModuleBase.QueryInterface( const IID: TGUID; out Obj): HResult;
begin
if GetInterface(IID, Obj)
then Result := 0
else Result := E_NOINTERFACE;
end;
function TDataModuleBase._AddRef: Integer;
begin
Inc(fRefCount);
Result := fRefCount;
end;
function TDataModuleBase._Release: Integer;
begin
Dec(fRefCount);
Result := fRefCount;
if fRefCount = 0 then Destroy;
end;
end.