git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES2/trunk@6 40301925-124e-1c4e-b97d-170ad7a8785b
52 lines
1004 B
ObjectPascal
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.
|