我们首先要建立一个ActiveX Library。将其保存为MailIEBand.Dpr;然后建立一个COM Object,将其保存为BandUnit.pas;然后建立一个Form,这个窗口将作为子窗口显示在IE工具栏中,将窗口的BorderStyle属性改为bsNone,添加一个TButton组件和一个TComboBox组件,将TButton的Caption属性改为获取全部,然后将窗口文件其保存为IEForm.pas。

在BandUnit中,需要建立一个实现上面提到的接口的TComObject对象。如下:

TGetMailBand = class(TComObject, IDeskBand, IObjectWithSite, IPersistStreamInit)


另外由于需要在COM服务器注册时添加一些注册表信息,所以还需要建立一个继承自TComObjectFactory类的对象,在对象的UpdateRegistry事件中编写代码添加附加的注册表信息。

下面的程序清单1-6到1-8是实现COM服务器的全部程序代码:


程序清单1-6 MailIEBand.dpr

Delphi开发IE中添加工具栏library MailIEBand;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏uses
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 ComServ,
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 BandUnit 
in 'BandUnit.pas',
Delphi开发IE中添加工具栏
,
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 MailIEBand_TLB 
in 'MailIEBand_TLB.pas';
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏exports
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 DllGetClassObject,
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 DllCanUnloadNow,
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 DllRegisterServer,
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 DllUnregisterServer;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end.
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏程序清单1
-7 BandUnit.pas
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏unit BandUnit;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
interface
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏uses
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 Windows, Sysutils, Messages, Registry, Shellapi, ActiveX, Classes, ComObj,
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Shlobj, Dialogs, Commctrl,ShDocVW,IEForm;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏type
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 TGetMailBand 
= class(TComObject, IDeskBand, IObjectWithSite, IPersistStreamInit)
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 
private
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   frmIE:TForm1;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   m_pSite:IInputObjectSite;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  m_hwndParent:HWND;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  m_hWnd:HWND;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  m_dwViewMode:Integer;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   m_dwBandID:Integer;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
protected
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
public
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function GetBandInfo(dwBandID, dwViewMode: DWORD; var pdbi: TDeskBandInfo):
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function ShowDW(fShow: BOOL): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function CloseDW(dwReserved: DWORD): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function ResizeBorderDW(var prcBorder: TRect; punkToolbarSite: IUnknown;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     fReserved: BOOL): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function GetWindow(
out wnd: HWnd): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function ContextSensitiveHelp(fEnterMode: BOOL): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function SetSite(
const pUnkSite: IUnknown ):HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function GetSite(
const riid: TIID; out site: IUnknown):HResult;stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function GetClassID(
out classID: TCLSID): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function IsDirty: HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function InitNew: HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function Load(
const stm: IStream): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function Save(
const stm: IStream; fClearDirty: BOOL): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   function GetSizeMax(
out cbSize: Largeint): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
const
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 Class_GetMailBand: TGUID 
= '{954F618B-0DEC-4D1A-9317-E0FC96F87865}';
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 
//以下是系统接口的IID
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏 IID_IUnknown: TGUID 
= (
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   D1:$
00000000;D2:$0000;D3:$0000;D4:($C0,$00,$00,$00,$00,$00,$00,$46));
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 IID_IOleObject: TGUID 
= (
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   D1:$
00000112;D2:$0000;D3:$0000;D4:($C0,$00,$00,$00,$00,$00,$00,$46));
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 IID_IOleWindow: TGUID 
= (
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   D1:$
00000114;D2:$0000;D3:$0000;D4:($C0,$00,$00,$00,$00,$00,$00,$46));
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 IID_IInputObjectSite : TGUID 
= (
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   D1:$f1db8392;D2:$
7331;D3:$11d0;D4:($8C,$99,$00,$A0,$C9,$2D,$BF,$E8));
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 sSID_SInternetExplorer : TGUID 
= '{0002DF05-0000-0000-C000-000000000046}';
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 sIID_IWebBrowserApp : TGUID
= '{0002DF05-0000-0000-C000-000000000046}';
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 
//面板所允许的最小宽度和高度。
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏 MIN_SIZE_X 
= 54;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 MIN_SIZE_Y 
= 22;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 EB_CLASS_NAME 
= 'GetMailAddress';
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏implementation
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏uses ComServ;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.GetWindow(
out wnd: HWnd): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  wnd:
=m_hWnd;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
=S_OK;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.ContextSensitiveHelp(fEnterMode: BOOL): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
=E_NOTIMPL;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.ShowDW(fShow: BOOL): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
if m_hWnd<>0 then
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
if fShow then
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     ShowWindow(m_hWnd,SW_SHOW)
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
else
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     ShowWindow(m_hWnd,SW_HIDE);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
=S_OK;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.CloseDW(dwReserved: DWORD): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
if frmIE<>nil then
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   frmIE.Destroy;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
= S_OK;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.ResizeBorderDW(var prcBorder: TRect;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   punkToolbarSite: IUnknown;fReserved: BOOL): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
=E_NOTIMPL;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.SetSite(
const pUnkSite: IUnknown):HResult;stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏var
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  pOleWindow:IOleWindow;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  pOLEcmd:IOleCommandTarget;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  pSP:IServiceProvider;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  rc:TRect;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
if Assigned(pUnkSite) then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   m_hwndParent :
= 0;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   m_pSite:
=pUnkSite as IInputObjectSite;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   pOleWindow :
= PunkSIte as IOleWindow;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
//获得父窗口IE面板窗口的句柄
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏   pOleWindow.GetWindow(m_hwndParent);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
if(m_hwndParent=0)then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     Result :
= E_FAIL;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     exit;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
//获得父窗口区域
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏   GetClientRect(m_hwndParent, rc);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
if not Assigned(frmIE) then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     
//建立TIEForm窗口,父窗口为m_hwndParent
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏     frmIE:
=TForm1.CreateParented(m_hwndParent);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     m_Hwnd:
=frmIE.Handle;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     SetWindowLong(frmIE.Handle, GWL_STYLE, GetWindowLong(frmIE.Handle,
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏      GWL_STYLE) Or WS_CHILD);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     
//根据父窗口区域设置窗口位置
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏     with frmIE 
do begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏      Left :
=rc.Left ;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏      Top:
=rc.top;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏      Width:
=rc.Right - rc.Left;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏      Height:
=rc.Bottom - rc.Top;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     frmIE.Visible :
= True;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     
//获得与浏览器相关联的Webbrowser对象。
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏     pOLEcmd:
=pUnkSite as IOleCommandTarget;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pSP:
=pOLEcmd as IServiceProvider;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     
if Assigned(pSP)then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏      pSP.QueryService(IWebbrowserApp, IWebbrowser2,frmIE.IEThis);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result :
= S_OK;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.GetSite(
const riid: TIID; out site: IUnknown):HResult;stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
if Assigned(m_pSite) then result:=m_pSite.QueryInterface(riid, site)
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
else
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   Result:
= E_FAIL;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.GetBandInfo(dwBandID, dwViewMode: DWORD; var pdbi: TDeskBandInfo):
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
=E_INVALIDARG;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
if not Assigned(frmIE) then frmIE:=TForm1.CreateParented(m_hwndParent);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
if(@pdbi<>nil)then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   m_dwBandID :
= dwBandID;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   m_dwViewMode :
= dwViewMode;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
if(pdbi.dwMask and DBIM_MINSIZE)<>0 then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pdbi.ptMinSize.x :
= MIN_SIZE_X;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pdbi.ptMinSize.y :
= MIN_SIZE_Y;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
if(pdbi.dwMask and DBIM_MAXSIZE)<>0 then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pdbi.ptMaxSize.x :
= -1;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pdbi.ptMaxSize.y :
= -1;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
if(pdbi.dwMask and DBIM_INTEGRAL)<>0 then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pdbi.ptIntegral.x :
= 1;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pdbi.ptIntegral.y :
= 1;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
if(pdbi.dwMask and DBIM_ACTUAL)<>0 then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pdbi.ptActual.x :
= 0;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pdbi.ptActual.y :
= 0;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
if(pdbi.dwMask and DBIM_MODEFLAGS)<>0 then
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pdbi.dwModeFlags :
= DBIMF_VARIABLEHEIGHT;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
if(pdbi.dwMask and DBIM_BKCOLOR)<>0 then
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     pdbi.dwMask :
= pdbi.dwMask and (not DBIM_BKCOLOR);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.GetClassID(
out classID: TCLSID): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  classID:
= Class_GetMailBand;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
=S_OK;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.IsDirty: HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
=S_FALSE;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.InitNew: HResult;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 Result :
= E_NOTIMPL;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.Load(
const stm: IStream): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
=S_OK;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.Save(
const stm: IStream; fClearDirty: BOOL): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
=S_OK;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏function TGetMailBand.GetSizeMax(
out cbSize: Largeint): HResult; stdcall;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Result:
=E_NOTIMPL;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
//TIEClassFac类实现COM组件的注册
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏type
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  TIEClassFac
=class(TComObjectFactory) //
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏  
public
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   procedure UpdateRegistry(Register: Boolean); 
override;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏procedure TIEClassFac.UpdateRegistry(Register: Boolean);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏var
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 ClassID: 
string;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 a:Integer;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  inherited UpdateRegistry(Register);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
if Register then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   ClassID:
=GUIDToString(Class_GetMailBand);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   with TRegistry.Create 
do
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏    
try
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     
//添加附加的注册表项
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏     RootKey:
=HKEY_LOCAL_MACHINE;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     OpenKey(
'\SOFTWARE\Microsoft\Internet Explorer\Toolbar',False);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     a:
=0;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     WriteBinaryData(GUIDToString(Class_GetMailBand),a,
0);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     OpenKey(
'\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved',True);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     WriteString (GUIDToString(Class_GetMailBand),EB_CLASS_NAME);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     RootKey:
=HKEY_CLASSES_ROOT;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     OpenKey(
'\CLSID\'+GUIDToString(Class_GetMailBand),False);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     WriteString(
'',EB_CLASS_NAME);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏    
finally
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     Free;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏    end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  end
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
else begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   with TRegistry.Create 
do
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
try
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     RootKey:
=HKEY_LOCAL_MACHINE;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     OpenKey(
'\SOFTWARE\Microsoft\Internet Explorer\Toolbar',False);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     DeleteValue(GUIDToString(Class_GetMailBand));
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     OpenKey(
'\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved',False);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     DeleteValue(GUIDToString(Class_GetMailBand));
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
finally
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     Free;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏initialization
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  TIEClassFac.Create(ComServer, TGetMailBand, Class_GetMailBand,
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
'GetMailAddress''', ciMultiInstance, tmApartment);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end.
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏程序清单1
-8 IEForm.pas
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏unit IEForm;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
interface
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏uses
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 SHDocVw,MSHTML, StdCtrls;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏type
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 TForm1 
= class(TForm)
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Button1: TButton;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  ComboBox1: TComboBox;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  procedure FormResize(Sender: TObject);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  procedure Button1Click(Sender: TObject);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 
private
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 
public
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  IEThis:IWebbrowser2;
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏var
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 Form1: TForm1;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏implementation
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏procedure TForm1.FormResize(Sender: TObject);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 With Button1 
do begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Left :
= 0;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Top :
= 0;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Height:
=Self.ClientHeight;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 With ComboBox1 
do begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Left :
= Button1.Width +3;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Top :
= 0;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Height:
=Self.ClientHeight;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  Width:
=Self.ClientWidth - Left;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏procedure TForm1.Button1Click(Sender: TObject);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏var
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 doc:IHTMLDocument2;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 all:IHTMLElementCollection;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 len,i,flag:integer;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 item:IHTMLElement;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 vAttri:Variant;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 
if Assigned(IEThis)then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  ComboBox1.Clear;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
//获得Webbrowser对象中的文档对象
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏  doc:
=IEThis.Document as IHTMLDocument2;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
//获得文档中所有的HTML元素集合
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏  all:
=doc.Get_all;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  len:
=all.Get_length;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  
//访问HTML元素集合中的每一个元素
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏  
for i:=0 to len-1 do begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   item:
=all.item(i,varempty) as IHTMLElement;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   
//如果该元素是一个链接
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏   
if item.Get_tagName = 'A'then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏    flag:
=0;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏    vAttri:
=item.getAttribute('protocol',flag);   //获得链接属性
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏    
//如果是mailto链接则将链接的目标地址添加到ComboBox1
Delphi开发IE中添加工具栏

Delphi开发IE中添加工具栏    
if vAttri = 'mailto:'then begin
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     vAttri:
=item.getAttribute('href',flag);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏     ComboBox1.Items.Add(vAttri);
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏    end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏   end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏  end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏 end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end;
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏
Delphi开发IE中添加工具栏end.
Delphi开发IE中添加工具栏
编译工程,关闭所有的IE窗口,然后点击Delphi菜单的Run | Register ActiveX Server 项注册服务器。然后打开IE,点击菜单 察看 | 工具栏 项,可以看到子菜单中多了一个GetMailAddress项,选中改项,工具栏就出现在IE工具栏中

相关文章: