对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。1 Z @0 I8 E! h6 `/ @. e
& V+ @# f+ j+ x% {& {+ x4 W, n8 S
Regsvr32.exe 的用法 3 P- g' w/ _% |8 l. R" O& D; D& m
4 v9 W9 C8 A4 s) \8 `& KRegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname ; Q) i! W3 y" X3 E
& ]6 P$ g4 V2 Z# o- H! H/ {
/u - Unregister server<BR/>
2 j6 c; q- |2 r: o: w# r3 h% f8 ?( ] /i - Call DllInstall passing it an optional [cmdline]; : d8 x6 @4 L( H# D- c: x
when used with /u calls dll uninstall
4 B. V' |0 D4 v+ T+ d /n - do not call DllRegisterServer; this option must ( v7 f8 ^; \/ _
be used with /i
: Z5 N2 W& J' w' e
( @) j+ ~1 Y4 K1 D2 q% c当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
0 V7 ]2 O2 {3 s5 e3 mhttp://msdn.microsoft.com/librar ... n32_error_codes.asp
0 N; A Y1 i3 S0 J/ s7 d# h( Q4 @. S% w$ c
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
h# c) Y6 ~9 H6 e% S" C3 }4 O2 oc:\regsvr32.exe sample.ocx
# O" |% v+ @& O% q
& X3 n* P1 q: s! nRegsvr32.exe 错误消息
+ k* Q2 e- b6 [! V1 _4 `/ q: N; t# a0 S! Z% a/ C
以下列表介绍了 RegSvr32 错误消息和可能的原因。 2 w& r$ `' X4 c
* d7 I0 I; a$ P+ ^6 }Unrecognized flag:/invalid_flag
# K" v3 U7 ~0 s, j$ p# ]+ U7 z# V) h
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 ( Y$ g+ D6 f4 J5 K0 V2 H. A7 I
7 l5 N+ Z; D6 q! u2 R2 v" U: \No DLL name specified.
# P; ^" Z3 i+ R* [9 W! F3 J& l5 ~, d/ H. Q
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。
, `: d8 J1 [8 l7 S/ r% m* X, ^2 P' `' u, J) ]' p3 w
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. 2 g) t. | w# Z( X- z ~
: W% b4 P1 a) j
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
% j4 a" ^' ~2 F" {" A: ^3 b% @9 z! x- F8 p& W: i
Dllname is not an executable file and no registration helper is registered for this file type. ; @* G) J) z: K. o
0 _9 n7 t7 U! R) u8 UDllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
/ m7 b% B2 X L6 Z, R% a3 g1 z6 a$ h8 J3 E% n
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
' W5 B7 U/ w' z" \6 j% p! Z
+ `" j4 n, \* a! sDllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
, Z1 d: w" B1 a$ [1 I
' D' d: |" Z& b: v a% r. KDllname is not self-registerable or a corrupted version is in memory. . b5 h# h; H; s
; s0 D8 U) l4 D7 b
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
# x; i! _& E' B197155 如何终止孤立进程
1 n: f( z" m! U. Q J7 ]8 H1 c! B9 G
4 F, l4 z2 l3 p0 ^OleInitialize failed (or OleUninitialize failed).
: N; o# f' `7 b: @2 J8 X
0 c: ~& Q! Z' a. cRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
( T; p1 g1 v4 r' J/ F& o/ p& p( A
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485
2 J/ h. c4 J5 W0 V: U7 E8 F6 q9 a$ z. [5 i! T" |6 \8 ^
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
8 n3 Z; |+ \( o& J) _7 n
4 G+ f+ z2 ^; { XLoadLibrary("Dllname") failed.GetLastError returns 0x00000002 $ I1 Y. E. |2 a
5 [ {4 j: b" g在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
: `3 P% S* m. `2 ?# X. i, U
3 g# c, J! |) a: GLoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f . @% [/ _7 M# M3 _0 g9 C3 P8 o; E
/ H# m, x0 M$ c; z( o- j/ H) G在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 / g; \# U+ X( c3 Y* H
" f+ V4 m2 w: D. ~' jDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
& D$ |. T! F0 K9 d2 e1 v3 M8 z" a: R7 J9 b+ c M
在 Winerror.h 中搜索字符串。 % M* J; A ]( {7 U" J) S9 o
Regsvr32.exe 和依赖项
: ~. B# ?+ D! h8 I' ^: ORegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。
5 J& z/ V- {( _2 v
' J6 T9 C7 D% F. W' @# H您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 . t' a v/ S8 C0 y0 b
247024 Tools Included with the Microsoft Windows 98 Resource Kit |