我们有一个项目可以编译为32位COM DLL和64位COM DLL(来自my earlier question的同一个) . 当我在Windows 7机器上注册时,两者都注册成功 . 当我在Windows Server 2003计算机上注册时,都成功注册 .
But 当我尝试在Windows Server 2008 R2标准SP1机器上注册DLL时,64位DLL成功注册,但 32-bit DLL失败并显示消息(原文如此):
The module ""%1"" may not compatible with the version of Windows that you're running. Check if the module is compatible with an x86 (32-bit) or x64 (64-bit) version of regsvr32.exe.
我不认为32位DLL可以与WS2003和Win7兼容,但不兼容WS2008 . 这是没有意义的 .
可能会发生什么?
6 回答
Regsvr32.exe的版本必须与您尝试注册的dll的32/64位相匹配 . 64位regsvr32无法加载32位dll,反之亦然 .
您可能需要显式调用位于%systemroot%\ SysWoW64 \ regsvr32.exe中的32位版本的regsrv32 .
从http://support.microsoft.com/kb/249873
Regsvr32.exe包含在Microsoft Internet Explorer 3.0或更高版本,Windows 95 OEM Service Release 2(OSR2)或更高版本以及Windows NT 4.0 Service Pack 5(SP5)或更高版本中 . Regsvr32.exe安装在系统(Windows Me / Windows 98 / Windows 95)或System32(Windows NT / Windows XP / Windows Vista / Windows 7)文件夹中 .
注意在64位版本的Windows操作系统上,有两个版本的Regsv32.exe文件:
64位版本是%systemroot%\ System32 \ regsvr32.exe .
32位版本是%systemroot%\ SysWoW64 \ regsvr32.exe .
Regsvr32.exe用法RegSvr32.exe具有以下命令行选项:Regsvr32 [/ u] [/ n] [/ i [:cmdline]] dllname
/ u - 取消注册server / i - 调用DllInstall传递一个可选的[cmdline];与/ u一起使用时调用dll uninstall / n - 不要调用DllRegisterServer;此选项必须与/ i / s一起使用 - 无声;不显示消息框(随Windows XP和Windows Vista一起添加)使用Regsvr32.exe时,它会尝试加载组件并调用其DLLSelfRegister函数 . 如果此尝试成功,Regsvr32.exe将显示一个指示成功的对话框 . 如果尝试失败,Regsvr32.exe将返回错误消息 . 这可能包括Win32错误代码 . 有关更多信息,请单击下面的文章编号,以查看Microsoft知识库中相应的文章:193625 WinInet错误代码(12001到12156)
这可能不是您的问题,但对于通过搜索相同的错误消息找到此问题的其他人可能会有用:
我有一个类似的问题:一个不能注册32位或64位版本的RegSvr32的DLL . 我加载了DLL Dependency Walker(depends.exe,http://www.dependencywalker.com/)并得到了一个更有用的消息:
Error: At least one file was not a 32-bit or 64-bit Windows module.
扫描模块列表中的CPU列可识别出有问题的模块 . (在我的例子中,它说“没有找到DOS或PE签名 . 这个文件不是有效的32位或64位Windows模块 . ”)
道德:Dependency Walker可能会提供比RegSvr32.exe更有用的错误消息 .
我通过将dll移动到c:\ windows \ syswow64 \目录(它在system32目录中不起作用)然后显式调用syswow64 \ regsvr32来注册它,例如
c:\ windows \ syswow64 \ regsvr32 yourdll.dll
顺便说一句,它在调用c:\ windows \ syswow64 \ regsvr32 c:\ windows \ syswow64 \ yourdll.dll时不起作用
我有同样的问题,但我用命令解决它
CD \ windows \ syswow64 regsvr32 c:\ filename . DLL
以管理员身份运行命令提示符修复了我的问题
从SysInternals使用Process Monitor .
1 . 按"Process Name" = regsvr32.exe过滤 .
2 . 尝试从正确版本的regsvr32.exe注册您的DLL(32位版本在SysWow64文件夹中)
3 . 进程监视器将跟踪计算机上发生的所有情况 .
4 . 首先通过消除注册表事件(暂时)开始分析
5 . 您可能会看到找到巫婆dll但未找到 .
这里有一个(非常)部分的屏幕截图,我们可以看到一些所需的dll
的threed32.ocx的regsvr32.exe
6 . 你的工作才刚刚开始 . 现在起 .