对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。
3 w: t# T0 v3 q
9 b, Y+ x7 {. U& @Regsvr32.exe 的用法
l2 J1 V; r; n5 q/ I' G& H3 y5 W: C, C- }. m1 w- C
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname
w! I) g i( O9 C* O5 f1 n! H, f4 m
/u - Unregister server<BR/> 9 Z9 r" Y4 z f. K. I. a
/i - Call DllInstall passing it an optional [cmdline]; 9 D6 q( ^* J. n* v
when used with /u calls dll uninstall & q* I' Z5 n) F9 P
/n - do not call DllRegisterServer; this option must
' {- n( ]0 `- {& B4 \0 V/ m be used with /i 2 E& D2 f; u8 l; q+ j! Q1 v& f1 w3 j
8 u0 @' |5 V! Z; D! w- J- `当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: + [# f8 w; O6 q! j+ j
http://msdn.microsoft.com/librar ... n32_error_codes.asp 6 r2 q9 A2 d" Z$ c( ^# Q& i1 p
: B% \' }* E" \( e' s( F. k( k2 U5 y$ M例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
. m. I& E" l: ?c:\regsvr32.exe sample.ocx
1 W" C' Y5 o" L6 {$ F: [. o( A% B2 s) v
Regsvr32.exe 错误消息
0 n1 `* _( z3 b2 J$ c* U4 E% @8 _6 W B. ]$ A6 d& e
以下列表介绍了 RegSvr32 错误消息和可能的原因。
& E0 |3 C' ^/ d6 }- a' v" G9 U. K6 z9 }, V
Unrecognized flag:/invalid_flag
8 S; I4 y0 E8 H8 ?* n' U4 t4 P5 ~9 I! Q, L: Z2 O; ?
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
' t3 Y/ U& N' O* C& V) A
) T# }; |7 b, d* g! k' k0 N# oNo DLL name specified. 9 l# o& q' g1 o$ {
) u: j& o0 N+ O1 B3 u( i未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 5 w8 {1 b% W7 Y% B6 p: @
8 n9 B f' X$ ] n1 SDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
. m6 L7 i0 R2 \" Y0 ^
. |5 D2 K, H! w. NDllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 . d- l; E( \1 B! h
" }( e, r/ K3 c5 t a7 _ a* Y% A$ EDllname is not an executable file and no registration helper is registered for this file type.
5 d! \0 Q' ?3 ]& r7 x# C) A. p$ E: Y& [ B& p3 v7 g, H9 y7 r4 u: s
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。 + k/ [- L, u9 z1 K% M- F
) P- w2 b# G _" z5 L
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
- o$ y0 a* _5 h7 `1 _! j2 U
. Q9 m% m6 T6 j( z3 c K3 JDllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。 + x+ }$ q* @+ q7 F; v
, U- m/ M* N3 ]- D# h- q5 l1 i3 H
Dllname is not self-registerable or a corrupted version is in memory.
/ Y3 l: }+ H" ?' U4 X3 o
# [' e; r) j; x" H, j% Z6 a例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
& V2 y! H% I+ ?; j1 t9 _197155 如何终止孤立进程 7 K7 X$ j1 ?9 V6 @
2 b" F I$ S9 d* T5 k6 e9 a
OleInitialize failed (or OleUninitialize failed). 5 o$ G. s0 n2 m! K8 O" L' d
& w2 h, p1 g+ _% v+ F3 z1 B9 gRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 % E8 ~( b, t* Y7 _3 V) }
6 O/ t7 n3 k1 ?% L# r. dLoadLibrary("Dllname") failed.GetlastError returns 0x00000485
: ]/ I: A! { q( I) I, Y
5 |% f1 Y* ~; v: \% [7 {; l6 T) F在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
; Q7 U4 ~) t/ C9 I* C$ ]# e. N( I8 Z2 j; h5 V1 f/ s
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 , B, e7 R# i7 Y6 O( x
/ c8 F1 \* V: U! X( P
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。 , X. K1 M6 a. p* S1 w# ]
8 e, Y4 F' n& j$ I0 V" @6 [2 DLoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
, M8 _* B" L2 ~1 g; y$ Q& v
+ ?: L9 B4 ~, B" n7 ^' r, C在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
9 I3 a: C2 Y9 F f# U, B& I8 f# } @
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串 ; ~5 ~9 A% z- B) L7 H! P# j
. q* a, u4 x2 x' S1 p
在 Winerror.h 中搜索字符串。
! m5 S! Q* g2 d/ y5 Q4 I2 J) C+ JRegsvr32.exe 和依赖项
5 S. I9 b# `" P8 |# eRegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 7 Y. j. l; J F( K2 ?3 L0 W
/ y0 n- S7 W0 c/ C; m! o您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 `$ L3 E) k8 @; k* v, @
247024 Tools Included with the Microsoft Windows 98 Resource Kit |