發信人:Tomm.bbs@csie.nctu.edu.tw (葛瑞菲) 日期:5 Jun 1997 03:20:09 GMT 標題:Re: (( 葛瑞菲 )) About POP3 Control. 信群:tw.bbs.comp.language 看板:programming 代號:<3J1gY8$vfi@csie.nctu.edu.tw> 組織:交大資工鳳凰城資訊站 ==> 在 fanghm@ms3.hinet.net ("FANG, Hong-ming") 的文章中提到: : 老哥: : 其實當初就是不知如何安裝客戶端的 POP3 ActiveX Control : 才會用MS-ICP的, 因為它會自動幫我安裝該ActiveX且Regist : .. 可是現在我真不知如何讓NMPATCH.ZIP中的pop3 control裝 : 入Client.........Help me!! 我該如何手動copy這popct.ocx及註冊它 : 或以何方法產生該安裝程式以利安裝該OCX到Client??? : thank you so much!! ActiveX 元件安裝註冊的問題,我建議您分為兩步驟: 1.找出這個 OCX Run-Time 需要哪些 DLL. 目前做 Componentware 的軟體廠商多半不是大廠,文件多半很簡陋,您可以以自己的應用程式 為測基準,利用一些公用程式 (例如 VC++ Sample PVIEW ... etc ) 找出 Run-Time 時該 Program 到底用了哪些 DLL . 以您的 POPCT.OCX 為例 , 應該會用到 : MSVCRT.DLL MSVCRT40.DLL OLEPRO32.DLL OLEAUTO32.DLL POPCT.OCX NMOCOD.DLL NMSCKN.DLL NMORENU.DLL 將這些 DLL/OCX 置入 InstallShiled 中 , 並指定未來會複製到 \windows\system 目錄下. 2.在您的程式一開始自動做 ActiveX Controls Register 的動作, 以下摘自錢達智先生 在 DelphiChat 發表的程式碼, Delphi/Borland C++Builder 的使用者可以利用這個 程序讓自己的 Application 具備 REGSVR32.EXE 的功能 , 適用於 Self-Register 的 OCX . // ------------------------------------------------------------ // OCX 登錄安裝 // ------------ // 使用說明: // InstallOcx(Ocx 的檔案名稱, True(登錄)/False(取消登錄) // 傳回值: True ==> 成功 False ==> 無法登錄/取消登錄 // // e.g. // if InstallOcx('d:\windows\system\html.ocx', False) then .. // if InstallOcx('d:\windows\system\html.ocx', True) then ... // // 注意事項: // 1. 在 Delphi IDE 執行 InstallOcx('xxx.ocx', False); 解除安 // 裝後, 雖然 Windows Register Database 已清除該 OCX 的登 // 錄資料, Delphi 仍需重新啟動才有反應. // 2. 本函數使用前,Delphi 2 uses 述句中不要忘了 uses Windows,SysUtils, // OleCtl, OleAuto; // Delphi 3 uses 述句中不要忘了 uses Windows,SysUtils,ActiveX,ComObj; // ------------------------------------------------------------ function InstallOcx( const sFileName: AnsiString; bSetup: boolean): boolean; var hOcx: THandle; funcRegister: TDllRegisterServer; funcUnRegister: TDllUnRegisterServer; begin Result := False; // 檢查檔案是否存在 if not FileExists(sFileName) then Raise EOleError.CreateFmt('找不到 %s', [sFileName]); // 載入 OCX (也是一個 DLL) hOcx := LoadLibrary(pchar(sFileName)); if hOcx < 32 then Raise EOleError.CreateFmt('無法載入 %s', [sFileName]); try // 查出 DllRegisterServer 的 Call address if bSetup then begin if @funcRegister = nil then Raise EOleError.CreateFmt('無法載入 %s 中的 DllRegisterServer', [sFileName]); // 執行 DllRegisterServer, 並與正常值比較 Result := funcRegister = S_OK; end else begin funcUnRegister := GetProcAddress(hOcx, 'DllUnregisterServer'); if @funcUnRegister = nil then Raise EOleError.CreateFmt('無法載入 %s 中的 DllUnregisterServer', [sFileName]); // 執行, 並與正常值比較 Result := funcUnRegister = S_OK; end; // 如果執行失敗, 提示訊息. if not Result then begin if bSetup then Raise EOleError.CreateFmt('無法登錄註冊 %s', [sFileName]) else Raise EOleError.CreateFmt('無法取消註冊 %s', [sFileName]); end; finally FreeLibrary(hOcx); end; end; -- 歡迎加入免費的 DelphiChat/BCBChat Mailing List,加入辦法請參見: 32 Bit Delphi 深度歷險 : http://www.aaa.hinet.net/delphi http://www.kpi.edu.tw/delphi http://ibmsrv.cc.nthu.edu.tw/DELPHI .