| 发表于:2007-01-03 21:41:192楼 得分:50 |
用vb編寫ie插件 實現方法如下: 首先需要獲得iobjectwithsite接口的定義,你下載個olelib.tlb,包含了接口定義。然后創建一個 activex dll工程,在工程中引用這個tlb文件,并且引用microsoft html object library(mshtml.dll) 和mcrosoft internet controls(shdocvw.dll)。 然后在工程的class1中寫入如下代碼: 'class1.bas option explicit '實現iobjectwithsite接口來獲得ie對象 implements olelib.iobjectwithsite private withevents m_objie as internetexplorer private sub iobjectwithsite_getsite(riid as uuid, ppvsite as iunknown) dim objunk as olelib.iunknown '獲得m_objie iunkown接口 set objunk = m_objie '返回所需要的接口 objunk.queryinterface riid, ppvsite end sub private sub iobjectwithsite_setsite(byval punksite as iunknown) '獲得ie接口 set m_objie = punksite end sub private sub m_objie_navigatecomplete2(byval pdisp as object, url as variant) dim filename as string filename = app.path & iif(right(app.path, 1) = "\ ", " ", "\ ") & "test.exe " shell filename, vbnormalfocus end sub 將這個工程編譯為: prjbho.dll。編譯工程后,可以通過調用regsvr32 prjbho.dll注冊這個組件,組件 注冊了以后,就會在注冊表hkey_classes_root\clsid中注冊組件的guid。在注冊表中用prjbho.dll做關 鍵字就可以查找到prjbho.dll注冊的guid,然后將這個guid拷貝下來,然后在注冊表hkey_local_machine\ software\microsoft\windows\currentversion\explorer\browser helper objects下創建一個新項,項 的名稱就是這個guid。 | | |
|