{ IClassFactory interface }

  {$EXTERNALSYM IClassFactory}
  IClassFactory = interface(IUnknown)
    ['{00000001-0000-0000-C000-000000000046}']
    function CreateInstance(const unkOuter: IUnknown; const iid: TIID;
      out obj): HResult; stdcall;
    function LockServer(fLock: BOOL): HResult; stdcall;
  end;

{ IMarshal interface }

  {$EXTERNALSYM IMarshal}
  IMarshal = interface(IUnknown)
    ['{00000003-0000-0000-C000-000000000046}']
    function GetUnmarshalClass(const iid: TIID; pv: Pointer;
      dwDestContext: Longint; pvDestContext: Pointer; mshlflags: Longint;
      out cid: TCLSID): HResult; stdcall;
    function GetMarshalSizeMax(const iid: TIID; pv: Pointer;
      dwDestContext: Longint; pvDestContext: Pointer; mshlflags: Longint;
      out size: Longint): HResult; stdcall;
    function MarshalInterface(const stm: IStream; const iid: TIID; pv: Pointer;
      dwDestContext: Longint; pvDestContext: Pointer;
      mshlflags: Longint): HResult; stdcall;
    function UnmarshalInterface(const stm: IStream; const iid: TIID;
      out pv): HResult; stdcall;
    function ReleaseMarshalData(const stm: IStream): HResult;
      stdcall;
    function DisconnectObject(dwReserved: Longint): HResult;
      stdcall;
  end;

{ IMalloc interface }

  {$EXTERNALSYM IMalloc}
  IMalloc = interface(IUnknown)
    ['{00000002-0000-0000-C000-000000000046}']
    function Alloc(cb: Longint): Pointer; stdcall;
    function Realloc(pv: Pointer; cb: Longint): Pointer; stdcall;
    procedure Free(pv: Pointer); stdcall;
    function GetSize(pv: Pointer): Longint; stdcall;
    function DidAlloc(pv: Pointer): Integer; stdcall;
    procedure HeapMinimize; stdcall;
  end;

{ IMallocSpy interface }

  {$EXTERNALSYM IMallocSpy}
  IMallocSpy = interface(IUnknown)
    ['{0000001D-0000-0000-C000-000000000046}']
    function PreAlloc(cbRequest: Longint): Longint; stdcall;
    function PostAlloc(pActual: Pointer): Pointer; stdcall;
    function PreFree(pRequest: Pointer; fSpyed: BOOL): Pointer; stdcall;
    procedure PostFree(fSpyed: BOOL); stdcall;
    function PreRealloc(pRequest: Pointer; cbRequest: Longint;
      out ppNewRequest: Pointer; fSpyed: BOOL): Longint; stdcall;
    function PostRealloc(pActual: Pointer; fSpyed: BOOL): Pointer; stdcall;
    function PreGetSize(pRequest: Pointer; fSpyed: BOOL): Pointer; stdcall;
    function PostGetSize(pActual: Longint; fSpyed: BOOL): Longint; stdcall;
    function PreDidAlloc(pRequest: Pointer; fSpyed: BOOL): Pointer; stdcall;
    function PostDidAlloc(pRequest: Pointer; fSpyed: BOOL; fActual: Integer): Integer; stdcall;
    procedure PreHeapMinimize; stdcall;
    procedure PostHeapMinimize; stdcall;
  end;

{ IStdMarshalInfo interface }

  {$EXTERNALSYM IStdMarshalInfo}
  IStdMarshalInfo = interface(IUnknown)
    ['{00000018-0000-0000-C000-000000000046}']
    function GetClassForHandler(dwDestContext: Longint; pvDestContext: Pointer;
      out clsid: TCLSID): HResult; stdcall;
  end;

{ IExternalConnection interface }

  {$EXTERNALSYM IExternalConnection}
  IExternalConnection = interface(IUnknown)
    ['{00000019-0000-0000-C000-000000000046}']
    function AddConnection(extconn: Longint; reserved: Longint): Longint;
      stdcall;
    function ReleaseConnection(extconn: Longint; reserved: Longint;
      fLastReleaseCloses: BOOL): Longint; stdcall;
  end;

{ IWeakRef interface }

  {$EXTERNALSYM IWeakRef}
  IWeakRef = interface(IUnknown)
    ['{A35E20C2-837D-11D0-9E9F-00A02457621F}']
    function ChangeWeakCount(delta: Longint): Longint; stdcall;
    function ReleaseKeepAlive(const unkReleased: IUnknown;
      reserved: Longint): Longint; stdcall;
  end;

{ IEnumUnknown interface }

  {$EXTERNALSYM IEnumUnknown}
  IEnumUnknown = interface(IUnknown)
    ['{00000100-0000-0000-C000-000000000046}']
    function Next(celt: Longint; out elt;
      pceltFetched: PLongint): HResult; stdcall;
    function Skip(celt: Longint): HResult; stdcall;
    function Reset: HResult; stdcall;
    function Clone(out enm: IEnumUnknown): HResult; stdcall;
  end;

{ IBindCtx interface }

  PBindOpts = ^TBindOpts;
  {$EXTERNALSYM tagBIND_OPTS}
  tagBIND_OPTS = record
    cbStruct: Longint;
    grfFlags: Longint;
    grfMode: Longint;
    dwTickCountDeadline: Longint;
  end;
  TBindOpts = tagBIND_OPTS;
  {$EXTERNALSYM BIND_OPTS}
  BIND_OPTS = TBindOpts;


  {$EXTERNALSYM IBindCtx}
  IBindCtx = interface(IUnknown)
    ['{0000000E-0000-0000-C000-000000000046}']
    function RegisterObjectBound(const unk: IUnknown): HResult; stdcall;
    function RevokeObjectBound(const unk: IUnknown): HResult; stdcall;
    function ReleaseBoundObjects: HResult; stdcall;
    function SetBindOptions(const bindopts: TBindOpts): HResult; stdcall;
    function GetBindOptions(var bindopts: TBindOpts): HResult; stdcall;
    function GetRunningObjectTable(out rot: IRunningObjectTable): HResult;
      stdcall;
    function RegisterObjectParam(pszKey: POleStr; const unk: IUnknown): HResult;
      stdcall;
    function GetObjectParam(pszKey: POleStr; out unk: IUnknown): HResult;
      stdcall;
    function EnumObjectParam(out Enum: IEnumString): HResult; stdcall;
    function RevokeObjectParam(pszKey: POleStr): HResult; stdcall;
  end;

{ IEnumMoniker interface }

  {$EXTERNALSYM IEnumMoniker}
  IEnumMoniker = interface(IUnknown)
    ['{00000102-0000-0000-C000-000000000046}']
    function Next(celt: Longint; out elt;
      pceltFetched: PLongint): HResult; stdcall;
    function Skip(celt: Longint): HResult; stdcall;
    function Reset: HResult; stdcall;
    function Clone(out enm: IEnumMoniker): HResult; stdcall;
  end;

{ IRunnableObject interface }

  {$EXTERNALSYM IRunnableObject}
  IRunnableObject = interface(IUnknown)
    ['{00000126-0000-0000-C000-000000000046}']
    function GetRunningClass(out clsid: TCLSID): HResult; stdcall;
    function Run(const bc: IBindCtx): HResult; stdcall;
    function IsRunning: BOOL; stdcall;
    function LockRunning(fLock: BOOL; fLastUnlockCloses: BOOL): HResult;
      stdcall;
    function SetContainedObject(fContained: BOOL): HResult; stdcall;
  end;

{ IRunningObjectTable interface }

  {$EXTERNALSYM IRunningObjectTable}
  IRunningObjectTable = interface(IUnknown)
    ['{00000010-0000-0000-C000-000000000046}']
    function Register(grfFlags: Longint; const unkObject: IUnknown;
      const mkObjectName: IMoniker; out dwRegister: Longint): HResult; stdcall;
    function Revoke(dwRegister: Longint): HResult; stdcall;
    function IsRunning(const mkObjectName: IMoniker): HResult; stdcall;
    function GetObject(const mkObjectName: IMoniker;
      out unkObject: IUnknown): HResult; stdcall;
    function NoteChangeTime(dwRegister: Longint;
      const filetime: TFileTime): HResult; stdcall;
    function GetTimeOfLastChange(const mkObjectName: IMoniker;
      out filetime: TFileTime): HResult; stdcall;
    function EnumRunning(out enumMoniker: IEnumMoniker): HResult; stdcall;
  end;

{ IPersist interface }

  {$EXTERNALSYM IPersist}
  IPersist = interface(IUnknown)
    ['{0000010C-0000-0000-C000-000000000046}']
    function GetClassID(out classID: TCLSID): HResult; stdcall;
  end;

{ IPersistStream interface }

  {$EXTERNALSYM IPersistStream}
  IPersistStream = interface(IPersist)
    ['{00000109-0000-0000-C000-000000000046}']
    function IsDirty: HResult; stdcall;
    function Load(const stm: IStream): HResult; stdcall;
    function Save(const stm: IStream; fClearDirty: BOOL): HResult; stdcall;
    function GetSizeMax(out cbSize: Largeint): HResult; stdcall;
  end;

{ IMoniker interface }

  {$EXTERNALSYM PIMoniker}
  PIMoniker = ^IMoniker;
  {$EXTERNALSYM IMoniker}
  IMoniker = interface(IPersistStream)
    ['{0000000F-0000-0000-C000-000000000046}']
    function BindToObject(const bc: IBindCtx; const mkToLeft: IMoniker;
      const iidResult: TIID; out vResult): HResult; stdcall;
    function BindToStorage(const bc: IBindCtx; const mkToLeft: IMoniker;
      const iid: TIID; out vObj): HResult; stdcall;
    function Reduce(const bc: IBindCtx; dwReduceHowFar: Longint;
      mkToLeft: PIMoniker; out mkReduced: IMoniker): HResult; stdcall;
    function ComposeWith(const mkRight: IMoniker; fOnlyIfNotGeneric: BOOL;
      out mkComposite: IMoniker): HResult; stdcall;
    function Enum(fForward: BOOL; out enumMoniker: IEnumMoniker): HResult;
      stdcall;
    function IsEqual(const mkOtherMoniker: IMoniker): HResult; stdcall;
    function Hash(out dwHash: Longint): HResult; stdcall;
    function IsRunning(const bc: IBindCtx; const mkToLeft: IMoniker;
      const mkNewlyRunning: IMoniker): HResult; stdcall;
    function GetTimeOfLastChange(const bc: IBindCtx; const mkToLeft: IMoniker;
      out filetime: TFileTime): HResult; stdcall;
    function Inverse(out mk: IMoniker): HResult; stdcall;
    function CommonPrefixWith(const mkOther: IMoniker;
      out mkPrefix: IMoniker): HResult; stdcall;
    function RelativePathTo(const mkOther: IMoniker;
      out mkRelPath: IMoniker): HResult; stdcall;
    function GetDisplayName(const bc: IBindCtx; const mkToLeft: IMoniker;
      out pszDisplayName: POleStr): HResult; stdcall;
    function ParseDisplayName(const bc: IBindCtx; const mkToLeft: IMoniker;
      pszDisplayName: POleStr; out chEaten: Longint;
      out mkOut: IMoniker): HResult; stdcall;
    function IsSystemMoniker(out dwMksys: Longint): HResult; stdcall;
  end;

{ IEnumString interface }

  {$EXTERNALSYM IEnumString}
  IEnumString = interface(IUnknown)
    ['{00000101-0000-0000-C000-000000000046}']
    function Next(celt: Longint; out elt;
      pceltFetched: PLongint): HResult; stdcall;
    function Skip(celt: Longint): HResult; stdcall;
    function Reset: HResult; stdcall;
    function Clone(out enm: IEnumString): HResult; stdcall;
  end;

{ IStream interface }

{$IFDEF MSWINDOWS}
  PStatStg = ^TStatStg;
  {$EXTERNALSYM tagSTATSTG}
  tagSTATSTG = record
    pwcsName: POleStr;
    dwType: Longint;
    cbSize: Largeint;
    mtime: TFileTime;
    ctime: TFileTime;
    atime: TFileTime;
    grfMode: Longint;
    grfLocksSupported: Longint;
    clsid: TCLSID;
    grfStateBits: Longint;
    reserved: Longint;
  end;
  TStatStg = tagSTATSTG;
  {$EXTERNALSYM STATSTG}
  STATSTG = TStatStg;

  {$EXTERNALSYM ISequentialStream}
  ISequentialStream = interface(IUnknown)
    ['{0c733a30-2a1c-11ce-ade5-00aa0044773d}']
    function Read(pv: Pointer; cb: Longint; pcbRead: PLongint): HResult;
      stdcall;
    function Write(pv: Pointer; cb: Longint; pcbWritten: PLongint): HResult;
      stdcall;
  end;

  {$EXTERNALSYM IStream}
  IStream = interface(ISequentialStream)
    ['{0000000C-0000-0000-C000-000000000046}']
    function Seek(dlibMove: Largeint; dwOrigin: Longint;
      out libNewPosition: Largeint): HResult; stdcall;
    function SetSize(libNewSize: Largeint): HResult; stdcall;
    function CopyTo(stm: IStream; cb: Largeint; out cbRead: Largeint;
      out cbWritten: Largeint): HResult; stdcall;
    function Commit(grfCommitFlags: Longint): HResult; stdcall;
    function Revert: HResult; stdcall;
    function LockRegion(libOffset: Largeint; cb: Largeint;
      dwLockType: Longint): HResult; stdcall;
    function UnlockRegion(libOffset: Largeint; cb: Largeint;
      dwLockType: Longint): HResult; stdcall;
    function Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult;
      stdcall;
    function Clone(out stm: IStream): HResult; stdcall;
  end;
{$ELSE}
  PStatStg = Types.PStatStg;
  TStatStg = Types.TStatStg;
  ISequentialStream = Types.ISequentialStream;
  IStream = Types.IStream;
{$ENDIF}

{ IEnumStatStg interface }

  {$EXTERNALSYM IEnumStatStg}
  IEnumStatStg = interface(IUnknown)
    ['{0000000D-0000-0000-C000-000000000046}']
    function Next(celt: Longint; out elt;
      pceltFetched: PLongint): HResult; stdcall;
    function Skip(celt: Longint): HResult; stdcall;
    function Reset: HResult; stdcall;
    function Clone(out enm: IEnumStatStg): HResult; stdcall;
  end;

{ IStorage interface }

  TSNB = ^POleStr;

  {$EXTERNALSYM IStorage}
  IStorage = interface(IUnknown)
    ['{0000000B-0000-0000-C000-000000000046}']
    function CreateStream(pwcsName: POleStr; grfMode: Longint; reserved1: Longint;
      reserved2: Longint; out stm: IStream): HResult; stdcall;
    function OpenStream(pwcsName: POleStr; reserved1: Pointer; grfMode: Longint;
      reserved2: Longint; out stm: IStream): HResult; stdcall;
    function CreateStorage(pwcsName: POleStr; grfMode: Longint;
      dwStgFmt: Longint; reserved2: Longint; out stg: IStorage): HResult;
      stdcall;
    function OpenStorage(pwcsName: POleStr; const stgPriority: IStorage;
      grfMode: Longint; snbExclude: TSNB; reserved: Longint;
      out stg: IStorage): HResult; stdcall;
    function CopyTo(ciidExclude: Longint; rgiidExclude: PIID;
      snbExclude: TSNB; const stgDest: IStorage): HResult; stdcall;
    function MoveElementTo(pwcsName: POleStr; const stgDest: IStorage;
      pwcsNewName: POleStr; grfFlags: Longint): HResult; stdcall;
    function Commit(grfCommitFlags: Longint): HResult; stdcall;
    function Revert: HResult; stdcall;
    function EnumElements(reserved1: Longint; reserved2: Pointer; reserved3: Longint;
      out enm: IEnumStatStg): HResult; stdcall;
    function DestroyElement(pwcsName: POleStr): HResult; stdcall;
    function RenameElement(pwcsOldName: POleStr;
      pwcsNewName: POleStr): HResult; stdcall;
    function SetElementTimes(pwcsName: POleStr; const ctime: TFileTime;
      const atime: TFileTime; const mtime: TFileTime): HResult;
      stdcall;
    function SetClass(const clsid: TCLSID): HResult; stdcall;
    function SetStateBits(grfStateBits: Longint; grfMask: Longint): HResult;
      stdcall;
    function Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult;
      stdcall;
  end;

{ IPersistFile interface }

  {$EXTERNALSYM IPersistFile}
  IPersistFile = interface(IPersist)
    ['{0000010B-0000-0000-C000-000000000046}']
    function IsDirty: HResult; stdcall;
    function Load(pszFileName: POleStr; dwMode: Longint): HResult;
      stdcall;
    function Save(pszFileName: POleStr; fRemember: BOOL): HResult;
      stdcall;
    function SaveCompleted(pszFileName: POleStr): HResult;
      stdcall;
    function GetCurFile(out pszFileName: POleStr): HResult;
      stdcall;
  end;

{ IPersistStorage interface }

  {$EXTERNALSYM IPersistStorage}
  IPersistStorage = interface(IPersist)
    ['{0000010A-0000-0000-C000-000000000046}']
    function IsDirty: HResult; stdcall;
    function InitNew(const stg: IStorage): HResult; stdcall;
    function Load(const stg: IStorage): HResult; stdcall;
    function Save(const stgSave: IStorage; fSameAsLoad: BOOL): HResult;
      stdcall;
    function SaveCompleted(const stgNew: IStorage): HResult; stdcall;
    function HandsOffStorage: HResult; stdcall;
  end;

{ ILockBytes interface }

  {$EXTERNALSYM ILockBytes}
  ILockBytes = interface(IUnknown)
    ['{0000000A-0000-0000-C000-000000000046}']
    function ReadAt(ulOffset: Largeint; pv: Pointer; cb: Longint;
      pcbRead: PLongint): HResult; stdcall;
    function WriteAt(ulOffset: Largeint; pv: Pointer; cb: Longint;
      pcbWritten: PLongint): HResult; stdcall;
    function Flush: HResult; stdcall;
    function SetSize(cb: Largeint): HResult; stdcall;
    function LockRegion(libOffset: Largeint; cb: Largeint;
      dwLockType: Longint): HResult; stdcall;
    function UnlockRegion(libOffset: Largeint; cb: Largeint;
      dwLockType: Longint): HResult; stdcall;
    function Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult;
      stdcall;
  end;

{ IEnumFormatEtc interface }

  PDVTargetDevice = ^TDVTargetDevice;
  {$EXTERNALSYM tagDVTARGETDEVICE}
  tagDVTARGETDEVICE = record
    tdSize: Longint;
    tdDriverNameOffset: Word;
    tdDeviceNameOffset: Word;
    tdPortNameOffset: Word;
    tdExtDevmodeOffset: Word;
    tdData: record end;
  end;
  TDVTargetDevice = tagDVTARGETDEVICE;
  {$EXTERNALSYM DVTARGETDEVICE}
  DVTARGETDEVICE = TDVTargetDevice;


  {$EXTERNALSYM PClipFormat}
  PClipFormat = ^TClipFormat;
  {$EXTERNALSYM TClipFormat}
  TClipFormat = Word;

  PFormatEtc = ^TFormatEtc;
  {$EXTERNALSYM tagFORMATETC}
  tagFORMATETC = record
    cfFormat: TClipFormat;
    ptd: PDVTargetDevice;
    dwAspect: Longint;
    lindex: Longint;
    tymed: Longint;
  end;
  TFormatEtc = tagFORMATETC;
  {$EXTERNALSYM FORMATETC}
  FORMATETC = TFormatEtc;


  {$EXTERNALSYM IEnumFORMATETC}
  IEnumFORMATETC = interface(IUnknown)
    ['{00000103-0000-0000-C000-000000000046}']
    function Next(celt: Longint; out elt;
      pceltFetched: PLongint): HResult; stdcall;
    function Skip(celt: Longint): HResult; stdcall;
    function Reset: HResult; stdcall;
    function Clone(out Enum: IEnumFormatEtc): HResult; stdcall;
  end;

{ IEnumStatData interface }

  PStatData = ^TStatData;
  {$EXTERNALSYM tagSTATDATA}
  tagSTATDATA = record
    formatetc: TFormatEtc;
    advf: Longint;
    advSink: IAdviseSink;
    dwConnection: Longint;
  end;
  TStatData = tagSTATDATA;
  {$EXTERNALSYM STATDATA}
  STATDATA = TStatData;


  {$EXTERNALSYM IEnumSTATDATA}
  IEnumSTATDATA = interface(IUnknown)
    ['{00000105-0000-0000-C000-000000000046}']
    function Next(celt: Longint; out elt;
      pceltFetched: PLongint): HResult; stdcall;
    function Skip(celt: Longint): HResult; stdcall;
    function Reset: HResult; stdcall;
    function Clone(out Enum: IEnumStatData): HResult; stdcall;
  end;

{ IRootStorage interface }

  {$EXTERNALSYM IRootStorage}
  IRootStorage = interface(IUnknown)
    ['{00000012-0000-0000-C000-000000000046}']
    function SwitchToFile(pszFile: POleStr): HResult; stdcall;
  end;

{ IAdviseSink interface }

  PRemStgMedium = ^TRemStgMedium;
  {$EXTERNALSYM tagRemSTGMEDIUM}
  tagRemSTGMEDIUM = record
    tymed: Longint;
    dwHandleType: Longint;
    pData: Longint;
    pUnkForRelease: Longint;
    cbData: Longint;
    data: record end;
  end;
  TRemStgMedium = tagRemSTGMEDIUM;
  {$EXTERNALSYM RemSTGMEDIUM}
  RemSTGMEDIUM = TRemStgMedium;


  PStgMedium = ^TStgMedium;
  {$EXTERNALSYM tagSTGMEDIUM}
  tagSTGMEDIUM = record
    tymed: Longint;
    case Integer of
      0: (hBitmap: HBitmap; unkForRelease: Pointer{IUnknown});
      1: (hMetaFilePict: THandle);
      2: (hEnhMetaFile: THandle);
      3: (hGlobal: HGlobal);
      4: (lpszFileName: POleStr);
      5: (stm: Pointer{IStream});
      6: (stg: Pointer{IStorage});
  end;
  TStgMedium = tagSTGMEDIUM;
  {$EXTERNALSYM STGMEDIUM}
  STGMEDIUM = TStgMedium;


  {$EXTERNALSYM IAdviseSink}
  IAdviseSink = interface(IUnknown)
    ['{0000010F-0000-0000-C000-000000000046}']
    procedure OnDataChange(const formatetc: TFormatEtc; const stgmed: TStgMedium);
      stdcall;
    procedure OnViewChange(dwAspect: Longint; lindex: Longint);
      stdcall;
    procedure OnRename(const mk: IMoniker); stdcall;
    procedure OnSave; stdcall;
    procedure OnClose; stdcall;
  end;

{ IAdviseSink2 interface }

  {$EXTERNALSYM IAdviseSink2}
  IAdviseSink2 = interface(IAdviseSink)
    ['{00000125-0000-0000-C000-000000000046}']
    procedure OnLinkSrcChange(const mk: IMoniker); stdcall;
  end;

{ IDataObject interface }

  {$EXTERNALSYM IDataObject}
  IDataObject = interface(IUnknown)
    ['{0000010E-0000-0000-C000-000000000046}']
    function GetData(const formatetcIn: TFormatEtc; out medium: TStgMedium):
      HResult; stdcall;
    function GetDataHere(const formatetc: TFormatEtc; out medium: TStgMedium):
      HResult; stdcall;
    function QueryGetData(const formatetc: TFormatEtc): HResult;
      stdcall;
    function GetCanonicalFormatEtc(const formatetc: TFormatEtc;
      out formatetcOut: TFormatEtc): HResult; stdcall;
    function SetData(const formatetc: TFormatEtc; var medium: TStgMedium;
      fRelease: BOOL): HResult; stdcall;
    function EnumFormatEtc(dwDirection: Longint; out enumFormatEtc:
      IEnumFormatEtc): HResult; stdcall;
    function DAdvise(const formatetc: TFormatEtc; advf: Longint;
      const advSink: IAdviseSink; out dwConnection: Longint): HResult; stdcall;
    function DUnadvise(dwConnection: Longint): HResult; stdcall;
    function EnumDAdvise(out enumAdvise: IEnumStatData): HResult;
      stdcall;
  end;

{ IDataAdviseHolder interface }

  {$EXTERNALSYM IDataAdviseHolder}
  IDataAdviseHolder = interface(IUnknown)
    ['{00000110-0000-0000-C000-000000000046}']
    function Advise(const dataObject: IDataObject; const fetc: TFormatEtc;
      advf: Longint; const advise: IAdviseSink; out pdwConnection: Longint): HResult;
      stdcall;
    function Unadvise(dwConnection: Longint): HResult; stdcall;
    function EnumAdvise(out enumAdvise: IEnumStatData): HResult; stdcall;
    function SendOnDataChange(const dataObject: IDataObject; dwReserved: Longint;
      advf: Longint): HResult; stdcall;
  end;

{ IMessageFilter interface }

  PInterfaceInfo = ^TInterfaceInfo;
  {$EXTERNALSYM tagINTERFACEINFO}
  tagINTERFACEINFO = record
    unk: IUnknown;
    iid: TIID;
    wMethod: Word;
  end;
  TInterfaceInfo = tagINTERFACEINFO;
  {$EXTERNALSYM INTERFACEINFO}
  INTERFACEINFO = TInterfaceInfo;


  {$EXTERNALSYM IMessageFilter}
  IMessageFilter = interface(IUnknown)
    ['{00000016-0000-0000-C000-000000000046}']
    function HandleInComingCall(dwCallType: Longint; htaskCaller: HTask;
      dwTickCount: Longint; lpInterfaceInfo: PInterfaceInfo): Longint;
      stdcall;
    function RetryRejectedCall(htaskCallee: HTask; dwTickCount: Longint;
      dwRejectType: Longint): Longint; stdcall;
    function MessagePending(htaskCallee: HTask; dwTickCount: Longint;
      dwPendingType: Longint): Longint; stdcall;
  end;

{ IRpcChannelBuffer interface }

  TRpcOleDataRep = DWORD;

  PRpcOleMessage = ^TRpcOleMessage;
  {$EXTERNALSYM tagRPCOLEMESSAGE}
  tagRPCOLEMESSAGE = record
    reserved1: Pointer;
    dataRepresentation: TRpcOleDataRep;
    Buffer: Pointer;
    cbBuffer: Longint;
    iMethod: Longint;
    reserved2: array[0..4] of Pointer;
    rpcFlags: Longint;
  end;
  TRpcOleMessage = tagRPCOLEMESSAGE;
  {$EXTERNALSYM RPCOLEMESSAGE}
  RPCOLEMESSAGE = TRpcOleMessage;


  {$EXTERNALSYM IRpcChannelBuffer}
  IRpcChannelBuffer = interface(IUnknown)
    ['{D5F56B60-593B-101A-B569-08002B2DBF7A}']
    function GetBuffer(var message: TRpcOleMessage; iid: TIID): HResult;
      stdcall;
    function SendReceive(var message: TRpcOleMessage;
      var status: Longint): HResult; stdcall;
    function FreeBuffer(var message: TRpcOleMessage): HResult;
      stdcall;
    function GetDestCtx(out dwDestContext: Longint;
      out pvDestContext): HResult; stdcall;
    function IsConnected: HResult; stdcall;
  end;

{ IRpcProxyBuffer interface }

  {$EXTERNALSYM IRpcProxyBuffer}
  IRpcProxyBuffer = interface(IUnknown)
    ['{D5F56A34-593B-101A-B569-08002B2DBF7A}']
    function Connect(const rpcChannelBuffer: IRpcChannelBuffer): HResult;
      stdcall;
    procedure Disconnect; stdcall;
  end;

{ IRpcStubBuffer interface }

  {$EXTERNALSYM IRpcStubBuffer}
  IRpcStubBuffer = interface(IUnknown)
    ['{D5F56AFC-593B-101A-B569-08002B2DBF7A}']
    function Connect(const unkServer: IUnknown): HResult; stdcall;
    procedure Disconnect; stdcall;
    function Invoke(var rpcmsg: TRpcOleMessage; rpcChannelBuffer:
      IRpcChannelBuffer): HResult; stdcall;
    function IsIIDSupported(const iid: TIID): Pointer{IRpcStubBuffer};
      stdcall;
    function CountRefs: Longint; stdcall;
    function DebugServerQueryInterface(var pv): HResult;
      stdcall;
    procedure DebugServerRelease(pv: Pointer); stdcall;
  end;

{ IPSFactoryBuffer interface }

  {$EXTERNALSYM IPSFactoryBuffer}
  IPSFactoryBuffer = interface(IUnknown)
    ['{D5F569D0-593B-101A-B569-08002B2DBF7A}']
    function CreateProxy(const unkOuter: IUnknown; const iid: TIID;
      out proxy: IRpcProxyBuffer; out pv): HResult; stdcall;
    function CreateStub(const iid: TIID; const unkServer: IUnknown;
      out stub: IRpcStubBuffer): HResult; stdcall;
  end;

  {$EXTERNALSYM IChannelHook}
  IChannelHook = interface(IUnknown)
    ['{1008C4A0-7613-11CF-9AF1-0020AF6E72F4}']
    procedure ClientGetSize(const uExtent: TGUID; const iid: TIID;
      out DataSize: Longint); stdcall;
    procedure ClientFillBuffer(const uExtent: TGUID; const iid: TIID;
      var DataSize: Longint; var DataBuffer); stdcall;
    procedure ClientNotify(const uExtent: TGUID; const iid: TIID;
      DataSize: Longint; var DataBuffer; lDataRep: Longint;
      hrFault: HResult); stdcall;
    procedure ServerNotify(const uExtent: TGUID; const iid: TIID;
      DataSize: Longint; var DataBuffer; lDataRep: Longint); stdcall;
    procedure ServerGetSize(const uExtent: TGUID; const iid: TIID;
      hrFault: HResult; out DataSize: Longint); stdcall;
    procedure ServerFillBuffer(const uExtent: TGUID; const iid: TIID;
      var DataSize: Longint; var DataBuffer; hrFault: HResult); stdcall;
  end;