把RegSvr32命令加入到右鍵選單的方法

2021-04-12 14:19:24 字數 1327 閱讀 1089

相信對於廣大開發人員來說,在設計windows元件過程中,或者在元件單元測試環節都少不了要與windows系統命令regsvr32打交道。

註冊與反註冊元件(包括dll,ocx)的一般做法都是在命令列手工敲入命令,這種做法對於上述需要頻繁使用該命令的情況來說就顯得很費事。隱隱約約記得在許久以前看到過一篇文章介紹了一些方法,這裡我就彙總一下,總共兩種方法,一種是手工修改登錄檔,一種是編寫登錄檔匯入項。

方法一:手工修改登錄檔

在hkey_classes_root/ocxfile/shell目錄下新增對應的兩個命令,在各自command項下預設字串分別寫入「regsvr32 "%1"」,「regsvr32 /u "%1"」就大功告成了。其實要想讓dll右鍵選單也有這種效果,那麼只要在hkey_classes_root/dllfile/shell目錄下照貓畫虎就ok了。

如下圖所示:

方法二:撰寫登錄檔匯入指令碼

windows registry editor version 5.00

[hkey_classes_root/ocxfile]

"noopen"="這些檔案是小關聯程式,可以為其他程式所用。修改它們可能會造成您的計算機功能降低。"

@="activex 控制項"

[hkey_classes_root/ocxfile/shell]

[hkey_classes_root/ocxfile/shell/regsvr32]

[hkey_classes_root/ocxfile/shell/regsvr32/command]

@="regsvr32 /"%1/""

[hkey_classes_root/ocxfile/shell/unregsvr32]

[hkey_classes_root/ocxfile/shell/unregsvr32/command]

@="regsvr32 /u /"%1/""

[hkey_classes_root/dllfile/shell]

[hkey_classes_root/dllfile/shell/regsvr32]

[hkey_classes_root/dllfile/shell/regsvr32/command]

@="regsvr32 /"%1/""

[hkey_classes_root/dllfile/shell/unregsvr32]

[hkey_classes_root/dllfile/shell/unregsvr32/command]

@="regsvr32 /u /"%1/""

然後起個名字(例如addregsvrcmdtopopmenu.reg),儲存為.reg型別的檔案。

最後雙擊該檔案,就大功告成了。

regsvr32命令介紹

regsvr32.exe是32位系統下使用的dll註冊和反註冊工具,使用它必須通過命令列的方式使用,格式是 regsvr32 u s n i cmdline dll檔名 命令可以在 開始 執行 的文字框中,也可以事先在bat批處理文件中編寫好命令。未帶任何引數是註冊dll檔案功能,其它引數對應功能如...

regsvr32命令用法說明

regsvr32是乙個用來註冊動態鏈結庫 dll 或activex控制項 ocx 檔案的命令,其用法如下 regsvr32 u s n i cmdline dllname u 解除伺服器註冊 s 無聲 不顯示訊息框 i 呼叫 dllinstall,給其傳遞乙個可選 cmdline 跟 u一起使用時,...

把tomcat加入到windows服務

一 安裝服務 在命令列中進入 tomcat路徑 bin 執行 service.bat install 說明 1 服務名和顯示名稱 service.bat中設定了預設的服務名稱,不同版本分別命名為tomcat4 tomcat5 tomcat6,如果需要自定義服務名或服務的顯示名稱,可在service....