对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。0 P& n* t7 I- J' v$ C
?. \3 w8 f+ [1 C1 fRegsvr32.exe 的用法
, \/ A z2 K$ o. g, ? _. K
y# D! |( o; w( E/ t' \RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname 6 J* s# G) a3 W; v& w
% g+ A9 @8 V' M! [9 e, y
/u - Unregister server<BR/>
6 y: z: W& `8 ^! B7 R /i - Call DllInstall passing it an optional [cmdline];
- S. C0 {9 l! e1 d/ R( O. Q1 @ when used with /u calls dll uninstall
1 Y7 B3 r: y4 t, X4 F; s; ~ /n - do not call DllRegisterServer; this option must ( j# w* c: f4 S; A
be used with /i 7 k! A- \' |. ?/ r2 i
. w2 p5 s4 ?$ p当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: . i6 r; x& u; P) O4 B5 ~, q
http://msdn.microsoft.com/librar ... n32_error_codes.asp
# v% v' Z. f" k) j) B' o& U' \' B W) N4 I! j2 ~2 r9 n$ @; w! u
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: & q" m, z7 Q C
c:\regsvr32.exe sample.ocx : s1 J" w8 r( S5 C! J9 Y0 q: b1 @
2 G: W6 d1 n q0 I. a v
Regsvr32.exe 错误消息 4 p# U! [ u# H8 P+ B9 C
P+ O5 p) C# q& |9 P4 B
以下列表介绍了 RegSvr32 错误消息和可能的原因。 & C# `9 p- s+ v( v- f5 Q0 S
3 x- x# T& W/ T9 t& M8 M; B! F
Unrecognized flag:/invalid_flag . ?, w% i* e! C' v3 m5 [
) C4 [* {- v8 E! F: n$ A$ o& x; y
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 ( D/ j$ \: r2 f m0 r
7 K f$ z- g8 N- mNo DLL name specified. ' J v$ ]" W. A
9 e) @! b9 G9 U- G- t: L6 i未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 : n. Y& O/ U& v& _! h
) r. W, t& e9 R. b/ K9 F ?# Q- ]2 H/ [Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. / J0 g% E7 ]' @7 a' A2 A, m! i: u
; V- }( c, Z7 O" s+ r2 a& cDllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 3 [) q; }7 ~. u
0 k5 n1 C; N# D$ rDllname is not an executable file and no registration helper is registered for this file type.
. I8 e8 C5 X0 X1 _1 z: Y! B& a5 T9 O7 {) n
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。 0 A! i8 r2 t/ C( q5 j
- |+ l: U1 z3 [Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. : b5 |+ k2 h+ O( p: N6 g
# u9 ~. j4 _( Q) ?: w0 i
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
" Y8 J A2 }! v- z) `
! ^+ S/ N6 P9 k- TDllname is not self-registerable or a corrupted version is in memory.
# {% K" X+ y: T3 e( G% X6 C: s$ f5 l8 m( G; o) G2 w: M, _
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: # R6 L# C4 b' f6 P" z8 Y5 j
197155 如何终止孤立进程 ; l; ~ ` L" y9 @7 B- t/ w8 Y* F2 d
) F3 K9 q. ^: {3 Z) a% a7 F; W9 _ zOleInitialize failed (or OleUninitialize failed).
" f8 a. _. J, L: S8 p( M5 m2 G! W- @3 t" M, @/ l' |
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 % `! D+ C$ I( L- X
# f( w& r* r' K$ c2 Q8 ILoadLibrary("Dllname") failed.GetlastError returns 0x00000485
' V0 `7 ^' L: r
6 c6 X/ @- u3 W' k% z" f, Q: b9 I在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
9 d4 \' H g# {* s) g5 D# x, B; j8 F, S1 o$ G* @0 Q6 L
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 7 v7 }7 h5 q* A- ^. l1 u4 e& N
( x5 L, _3 N3 ?
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
; v0 V, w3 i- J% s* N0 l" F# L' C, Y& U
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f $ v/ K) |& {% n _! K7 Z. T* C. J
% B! B. Q# O* p- ^5 B; u9 S' _, ^$ l
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 * x9 {5 d* p! f1 g
- `" t+ z( Q+ u/ X6 }DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
/ [ X( q& }. e7 }; i; N$ v. }3 X0 y( L) H; s( ?
在 Winerror.h 中搜索字符串。
. g: v3 r6 I. ]- i! }* uRegsvr32.exe 和依赖项
5 v$ _3 D+ N$ \( [RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 % s, ?2 o* e0 G- C
$ E( ^& n1 v1 b E1 N( y) h
您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
: \3 Y* M8 s& E247024 Tools Included with the Microsoft Windows 98 Resource Kit |