简体   繁体   English

RegSvr32 退出代码文档?

[英]RegSvr32 exit codes documentation?

I played with RegSvr32.exe to register a COM Server and got next exit codes:我使用RegSvr32.exe来注册 COM 服务器并获得下一个退出代码:

0 - when registering properly normal DLL Com Server 0 - 正确注册正常的 DLL Com Server 时

3 - when try registering fake DLL Com Server (simple text file renamed to .DLL 3 - 当尝试注册假 DLL Com Server 时(简单的文本文件重命名为 .DLL

4 - when try registering simple DLL, not Com Server 4 - 尝试注册简单的 DLL 时,而不是 Com Server

Question: where I can find official (or non-official but good) description of all possible exit codes and their meaning?问题:我在哪里可以找到所有可能的退出代码及其含义的官方(或非官方但很好的)描述?

Search on internet didn't give me result, on SO I found this topic where is written that exit codes are the same with windows system error code, but I didn't understand why then when try registering bad file I am obtaining code = 3 = ERROR_PATH_NOT_FOUND , and when registering non-COM DLL - 4 = ERROR_TOO_MANY_OPEN_FILES ?在互联网上搜索没有给我结果,所以我发现这个主题写的退出代码与 Windows 系统错误代码相同,但我不明白为什么然后尝试注册错误文件时我正在获取代码 = 3 = ERROR_PATH_NOT_FOUND ,并且在注册非 COM DLL 时 - 4 = ERROR_TOO_MANY_OPEN_FILES For me it doesn't sound logically.对我来说,这听起来不合逻辑。

The exit codes are not documented.退出代码没有记录。 The documentation is here:文档在这里:

However, the source code for a version REGSVR32.EXE is shipped with Visual Studio 2008. This gives its version as 4.0.0, so is not the same as the one shipped with windows, which reports version 6.但是,版本 REGSVR32.EXE 的源代码随 Visual Studio 2008 一起提供。这使它的版本为 4.0.0,因此与 Windows 随附的版本不同,后者报告版本 6。

A quick look shows these:快速浏览显示这些:

#define FAIL_ARGS   1 // Invalid Argument
#define FAIL_OLE    2 // OleInitialize Failed
#define FAIL_LOAD   3 // LoadLibrary Failed
#define FAIL_ENTRY  4 // GetProcAddress failed
#define FAIL_REG    5 // DllRegisterServer or DllUnregisterServer failed.

Reading the source code suggests that under no circumstances does it return any other code than the ones above and zero for success, which proves it isn't the same as the Windows one.阅读源代码表明,在任何情况下,它都不会返回上述代码以外的任何其他代码,成功则返回零,这证明它与 Windows 不同。

I suspect that the difference in return codes is if it gets as far as GetProcAddress, it then returns the exit code from the function it calls, instead of just always returning 5.我怀疑返回代码的不同之处在于,如果它到达 GetProcAddress,那么它会从它调用的函数中返回退出代码,而不是总是返回 5。

Ideally they would have made it use GetLastError to get a more useful exit code, but I suspect there are too many tools (eg third party install programs) which now depend on exit codes 2-4, and it is too late to change it.理想情况下,他们会使用 GetLastError 来获得更有用的退出代码,但我怀疑有太多工具(例如第三方安装程序)现在依赖于退出代码 2-4,现在更改它为时已晚。

Also seeWhat do the various regsvr32 exit codes mean?另请参阅各种 regsvr32 退出代码的含义是什么? on Raymond Chen's blog on MSDN.在 Raymond Chen 在 MSDN 上的博客上。

Visual Studio used to ship with a MFC sample that was actually the source for the RegSvr32 utility and I remember going through that to harvest the exit codes: Visual Studio 曾经附带一个 MFC 示例,它实际上是 RegSvr32 实用程序的源代码,我记得通过它来收集退出代码:

FAIL_ARGS   1
FAIL_OLE    2
FAIL_LOAD   3
FAIL_ENTRY  4  // Not ERROR_TOO_MANY_OPEN_FILES but as expected "could not resolve 
               // DLLRegisterServer" as your using an invalid DLL
FAIL_REG    5

I can't find the sample, but if I Google for what I extracted there is this: http://web.archive.org/web/20140803013714/http://support.microsoft.com:80/kb/207132 which has matching codes so it looks like that KB demo code was also taken from RegSvr.我找不到样本,但如果我用谷歌搜索我提取的内容,那就是: http : //web.archive.org/web/20140803013714/http : //support.microsoft.com : 80/kb/ 207132有匹配的代码,所以看起来 KB 演示代码也取自 RegSvr。 Its trivial to work out the reasons behind each of the failure codes.找出每个故障代码背后的原因很简单。

Ben's answer is correct, though, do take note that error code 3 is also given as a result if Ben 的回答是正确的,但请注意,如果出现以下情况,也会给出错误代码 3

  • the .DLL could not be found找不到 .DLL
  • the .DLL was locked by another process and could not be read .DLL 被另一个进程锁定,无法读取
  • the process had insufficient rights to open the file.该进程没有足够的权限打开文件。 Eg, not running with admin rights when needed (with specific files or common files on the C drive)例如,在需要时不以管理员权限运行(使用 C 盘上的特定文件或公共文件)

> #define FAIL_LOAD 3 // LoadLibrary Failed > #define FAIL_LOAD 3 // LoadLibrary Failed

Feels a little bit vague, but the LoadLibrary is meant as DLLs referred within the specific DLL.感觉有点模糊,但 LoadLibrary 是指在特定 DLL 中引用的 DLL。 Using an application such as Depends , you can find all references, including missing ones.使用Depends等应用程序,您可以找到所有引用,包括缺失的引用。 Take note that a missing reference does not always result an error code 3 (in cases where the DLL actually didn't use it)请注意,缺少引用并不总是导致错误代码 3(在 DLL 实际未使用它的情况下)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM