⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uiocprtl.pas

📁 楠楠写的DBiocp例子都是源码
💻 PAS
字号:
unit uIOCPRTL;

interface

uses
   SysUtils, Windows, Contnrs, Classes;

type

  //实现接口的对象
  TInterObject = class (TObject, IUnknown)
  protected
    FRefCount: Integer;
  public
    function QueryInterface(const IID: TGUID; out Obj): HResult; virtual; stdcall;
    function _AddRef: Integer; stdcall;
    function _Release: Integer; stdcall;

    constructor Create;
    destructor Destroy; override;
  end;

 
implementation



//实现接口的对象
constructor TInterObject.Create;
begin
  inherited Create;
  FRefCount := 1;
end;

destructor TInterObject.Destroy;
begin
  inherited Destroy;
end;

function TInterObject.QueryInterface(const IID: TGUID; out Obj): HResult;
begin
  if GetInterface(IID, Obj) then
    Result := S_OK
  else
    Result := E_NOINTERFACE;
end;

function TInterObject._AddRef: Integer;
begin
  Result := InterlockedIncrement(FRefCount);
end;

function TInterObject._Release: Integer;
begin
  Result := InterlockedDecrement(FRefCount);
  if Result = 0 then
    Destroy; 
end;

//哈索表

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -