对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。 U5 R/ [( r9 R# l2 b. m' N
" m+ l* u: ~1 A% g- P" ^, l% ~( F
Regsvr32.exe 的用法 1 Y- p' |4 J2 ]& {4 `5 Q
0 B( y) i: h/ dRegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname & f9 D9 g7 h3 T- P
1 _0 t* j4 B! W
/u - Unregister server<BR/>
1 @7 {3 Q' u' w, m3 N: \; m /i - Call DllInstall passing it an optional [cmdline]; ; Y$ Z) }) `" p2 o* h/ T! Q
when used with /u calls dll uninstall
/ K. c( o* l5 |* n( j /n - do not call DllRegisterServer; this option must + w9 r2 Q( f( O! t+ x
be used with /i
2 m# w* L5 H8 Y- X7 r: w* o
! s& _5 }9 U; j( j% |当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
+ z$ B0 F3 A. B0 F9 x* _7 Dhttp://msdn.microsoft.com/librar ... n32_error_codes.asp 5 V; F4 |5 o# h9 T
5 n' |4 i7 s( c2 A* v例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
8 x% z; L y9 N2 U8 c7 |c:\regsvr32.exe sample.ocx 8 }* r& U9 B4 @6 h% F7 H
: L+ h4 k. B6 m. @) x
Regsvr32.exe 错误消息
; I- d' E3 H7 Z: V5 C& {5 e; Q4 O8 s0 X
以下列表介绍了 RegSvr32 错误消息和可能的原因。
2 b/ x# l7 l2 w4 O% f1 p6 I0 Q& L* |3 f3 n
Unrecognized flag:/invalid_flag & T& g7 h5 I2 s4 n( [) |! h
6 ?! |, k1 P% Q: c( i( E/ ?
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
2 ~0 y$ D$ q/ v$ T4 E0 I& s" e
% P. {9 U9 \. `5 \! K& |No DLL name specified. 7 F" u$ u3 q- U; v, N G7 D
% @8 `3 Y F$ ~+ d) {9 p
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。
, r4 G2 I; W" d* t2 R0 S* P
7 e4 f# Q/ U/ w6 xDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
) ^; \ y( J+ w' W' c# \; w1 M' D4 v" C `7 s+ k h6 Y: r
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
) a. x2 ~9 k3 D3 u0 k9 C+ ?2 g8 z; ~+ A. Z) A) y
Dllname is not an executable file and no registration helper is registered for this file type. 0 a2 a8 e2 Z4 A4 t' ?% T; d
; U4 w8 I! E8 x7 [1 d3 ^ eDllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。 ) x! [$ W* A+ o" m
$ z, H: V( q8 ]* W, K8 {: m( ~
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
2 x* C, B& }; o4 h5 y# o6 U0 E) i
0 l: c% N! [2 i9 N4 ^' ]) sDllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
0 B! C( J7 z9 X" [! _
6 d7 m6 u/ }3 k% r! W+ r2 Y' JDllname is not self-registerable or a corrupted version is in memory. 7 x; I+ n+ N' k( m, _3 l& ?1 h4 `
" e. U. Z6 k1 a例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: ' K7 `7 o/ B& H
197155 如何终止孤立进程 ; m) G9 j" R! s% i
7 Q# r3 s9 U N! _/ K; Q+ q
OleInitialize failed (or OleUninitialize failed). + \0 d2 s% ?3 | e! z
# \+ C) W% g; j- r$ JRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
" B4 ^) |2 W& f7 I1 Z
; {) l% g- C; s3 w$ X' o+ E3 @- sLoadLibrary("Dllname") failed.GetlastError returns 0x00000485 - X3 o- u: S7 [/ {
. H1 d: C# U+ \( k* Y3 @2 }在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 + E4 U. k% |# b0 j% ]
) A* x+ } Z6 X) O4 u
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002
9 g0 u: A) O# r6 Y
2 ~1 z9 {, L5 u% w在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
' p' k2 L( A5 I0 X' @ n8 K* H5 R; W+ [- Q) ` q4 t0 W2 [& }
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f : l% M9 D' B* h$ M
6 W) q! S" ]% @
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
8 E5 P4 e( {& i$ X' }" J0 v# q; {; { F8 f
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
) Y5 s' @+ _2 R+ D) s$ @ Z3 J; r! r# v' ^8 b7 W0 u
在 Winerror.h 中搜索字符串。
* T ]5 P- z/ R% M. f& B, J \& M% a9 XRegsvr32.exe 和依赖项 7 [* ~* n, M3 X( f2 t7 ~
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。
- _: h2 h0 x, Z, n$ x1 L. @9 R! G0 v, J! t5 R6 ~5 o e
您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
1 q$ K7 v2 G3 w+ @/ V5 E s, L* w247024 Tools Included with the Microsoft Windows 98 Resource Kit |