Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
572 views
in Technique[技术] by (71.8m points)

windows - RegSvr32 exit codes documentation?

I played with RegSvr32.exe to register a COM Server and got next exit codes:

0 - when registering properly normal DLL Com Server

3 - when try registering fake DLL Com Server (simple text file renamed to .DLL

4 - when try registering simple DLL, not 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? For me it doesn't sound logically.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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.

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.

Ideally they would have made it use GetLastError to get a more useful exit code, but I suspect there are too many tools (e.g. third party install programs) which now depend on exit codes 2-4, and it is too late to change it.

Also see What do the various regsvr32 exit codes mean? on Raymond Chen's blog on MSDN.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...