对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。 j3 s' `" c! u/ f
1 f: _+ I7 a' U' `
Regsvr32.exe 的用法
3 Z9 g) S# l0 l f1 X2 b9 N3 Z+ i: [+ A6 X7 E* Q2 T, y3 n2 z: L2 V
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname
! ?5 z. o" Q& s) s6 q2 G5 H% _; `% Q" ^* P* Q7 K# v( B* Y
/u - Unregister server<BR/> 7 ~4 ~6 l2 u0 q% I; {5 N3 Q2 |" j
/i - Call DllInstall passing it an optional [cmdline];
: P( _( b' f" g& n5 Y. I$ X0 L when used with /u calls dll uninstall $ l, j" z+ V9 m7 M
/n - do not call DllRegisterServer; this option must - ^- J9 t) x% Y! Q$ { c$ f
be used with /i % H" K& v) O3 a) h) T
6 f, J) t) V- ?& S; J
当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
# F% P; @5 J$ i( {( Zhttp://msdn.microsoft.com/librar ... n32_error_codes.asp
8 T R$ j; D5 F3 w' v8 C- B4 f* V
7 r5 n% r5 }) P7 J+ K/ `4 C3 L例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
) C# `* }: k( k4 S3 H/ Hc:\regsvr32.exe sample.ocx 0 W6 E) x. u! ]
& T; |8 E, Y: Z) S( }4 l) [# A
Regsvr32.exe 错误消息
5 w$ W, d3 P! b8 \
3 F$ {4 i" ^( \0 Y以下列表介绍了 RegSvr32 错误消息和可能的原因。
& S* e8 @0 o: E! q2 V
4 m/ C: V6 c. y! tUnrecognized flag:/invalid_flag 6 R- `9 T. D, Q/ i1 m
& ^, v7 i: A. q+ _
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
8 W6 d$ o$ {$ E5 T8 V& v9 ?0 X; H: p& t
No DLL name specified.
1 e* }5 ]1 A8 L; Q- B# J
& v4 k0 g/ X7 v' ~4 j未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。
% c8 z6 y* X" b; o) f3 z; i) }" e6 j' A- N- B: [ R2 |
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
2 C6 T/ w, f, `4 K" t) ]/ W) e) h& b6 G" ?0 B' @4 h
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 6 d' y8 `1 A6 |1 k' | x7 J
: h$ e# [- R3 e* W% b
Dllname is not an executable file and no registration helper is registered for this file type.
( x8 L$ ]1 V u0 b- a% D: I6 p4 N0 a' u) k: m i$ t
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
# S6 o" a6 {. z; }" S! Y1 G( W9 j7 `) a. t: |
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. % C* u/ x2 {- S$ I
0 d# ^4 I1 P/ G% ?0 b& L: m. p1 \/ N
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
5 g$ q& E8 t2 L2 Y* k, H, v8 b g9 g/ [9 U- |+ r
Dllname is not self-registerable or a corrupted version is in memory.
( W9 d1 p/ ^8 A3 ?1 a E
$ |) k: T0 a' w例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: * [8 ` X) r7 M' { R
197155 如何终止孤立进程 1 E5 P0 C8 ^0 ~! b7 D
0 L* S& ^) L5 D9 k3 ~, B) i
OleInitialize failed (or OleUninitialize failed). Z+ w8 @, O B: _; E" g/ }$ c- w5 Q
" k5 i' }0 }, O ?Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
+ m3 ]7 V ?! Y( w: K" b" E
, _' q& h6 c- aLoadLibrary("Dllname") failed.GetlastError returns 0x00000485 1 S* K# B5 R9 P
5 U9 L, s9 a: A
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 : j& s# y2 S1 H% [0 r0 o' y& T
5 x5 q- E# s5 a! t9 s n/ _LoadLibrary("Dllname") failed.GetLastError returns 0x00000002
# Y1 U$ j9 U% X7 j6 N
9 m# ~/ |! B# b; q, P在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
- C4 S9 v% L. N! {4 o( C9 i, W0 O' k/ Y
9 X" ], x4 G3 V0 W$ {, M- tLoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
. y+ F( a, ]; j8 o! ]% O; i8 \& Q- j3 ^- p m9 C* t9 z
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
& y' P' Y5 r$ [) k9 K5 J" h0 J2 P. _# \/ ~4 t1 y" J4 d
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
7 B8 [9 O& f4 b- }$ t8 q( \; _0 d- w# l: @0 V
在 Winerror.h 中搜索字符串。
$ H; |- N# e7 D8 JRegsvr32.exe 和依赖项
i7 X T( }3 ]' T; A% ERegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 ; ~. ~% T2 |2 c. `
4 L1 \" K. v: V, _! x; m# N
您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
6 E( N" x% H! ]247024 Tools Included with the Microsoft Windows 98 Resource Kit |