点击Delphi菜单 File | New 。在 ActiveX 页面中选择Active Library ,然后点击 OK 按钮。然后用同样的方法建立一个COM Object。在COM Object Wizard 窗口中,将复选框 Included type library 去掉。然后在Class Name中输入IEHelper,在Implemented Interface 中输入:IDispatch;IObjectwithSite 。然后点击 OK 按钮建立一个COM组件。
    保存工程,将工程保存为IEHelper.dpr,将Unit1保存为IEHelperUnit.pas。下面是IEHelperUnit.pas的具体代码:摘录自www.hktk.com

解决方案 »

  1.   

    unit iehelperunit;
    interface
    uses
    WIndows, Comobj, ActiveX, SHDOCVW, MSHTML,Dialogs;
    type
      TIEHelperFactory = class(TComObjectFactory)
      private
        procedure AddKeys;
        procedure RemoveKeys;
      public
        procedure UpdateRegistry(Register: Boolean); override;
      end;
      TIEHelper = class(TComObject, IDispatch, IObjectWithSite)
      public
        function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
        function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
        function GetIDsOfNames(const IID: TGUID; Names: Pointer;
          NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
        function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
          Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
        function SetSite(const pUnkSite: IUnknown): HResult; stdcall;
        function GetSite(const riid: TIID; out site: IUnknown): HResult; stdcall;
      private
        IE: IWebbrowser2;
        Cookie: Integer;
      end;const
      Class_IEHelper: TGUID = '{3D898C55-74CC-4B7C-B5F1-45913F368388}';
    implementationuses ComServ, Registry, SysUtils;