70

【茶包射手日記】在Windows x64註冊OCX/DLL元件

 2 years ago
source link: https://blog.darkthread.net/blog/regsvr32-32bit-dll-ocx-on-x64/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
【茶包射手日記】在Windows x64註冊OCX/DLL元件-黑暗執行緒

接獲報案,在Windows 2008註冊OCX失敗。開啟cmd.exe執行regsvr32 boo.ocx時傳回錯誤訊息:

The module "c:\windows\system32\boo.ocx” failed to load. Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files. The specified module could not be found.
無法載入模組 c:\windows\system32\boo.ocx"。 請確定二進位檔儲存於指定的路徑,或進行偵測以檢查二進位檔或相依 .DLL 檔是否發生問題。找不到指定的模組。

雖然訊息指出問題出在找不到檔案,但確定OCX檔案是存在的,聯想到問題可能出在Windows平台為x64,但OCX是用32位元開發的關係。爬文後確認此點,在x64平台註冊32位元元件(OCX, DLL)應使用c:\windows\sysWOW64\regsvr32.exe,而非c:\windows\system32\regsvr32.exe! (發現有趣的事: system"32"下的regsvr32.exe是64位元版,sysWOW"64"下的regsvr32.exe才是32位元版。XD)

將boo.ocx複製到c:\windows\sysWOW64,並使用同目錄下的regsvr32.exe執行註冊。以為就此打完收工,但又接到第二則錯誤訊息:

"boo.ocx" was loaded but the call to DllRegisterServer failed with error code 0x80040200
模組boo.ocx已載入, 但是呼叫 DllRegisterServer 失敗, 錯誤碼為 0x80040200

原因: 同事因不熟悉UAC的眉角,在啟動cmd.exe時未Run As Administrator提升為管理者權限,導致0x80040200權限不足錯誤(印象中,權限不足代碼多為0x80004005,本例不然)。重新升為管理者權限執行cmd.exe,註冊成功!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK