对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。' H( }$ B: L5 [5 B# C( w) o4 v- h
4 W" D: `9 d$ M+ L N- U3 H4 n
Regsvr32.exe 的用法 8 b# Z0 ~( @( H2 y$ h) ?6 M
# o$ k' T" O# N" ?, c n
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname + M8 [& ]; {8 @4 P( H- ]0 q# N2 v
" @. L/ b7 Z I8 h& V /u - Unregister server<BR/>
p, z1 p# h5 O, _ A /i - Call DllInstall passing it an optional [cmdline]; # q6 x: z* [3 j7 K" N5 v
when used with /u calls dll uninstall 1 E0 @$ j6 d& t! M" r1 g- b H
/n - do not call DllRegisterServer; this option must
7 T$ l' D! Z2 w0 K4 H be used with /i 5 Z* y0 B6 ~( J% C7 J+ C; H- E8 y
9 T) n$ Q8 Y; |7 m0 I当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
: _% ?# k" l( v$ l6 L0 \3 K$ f$ thttp://msdn.microsoft.com/librar ... n32_error_codes.asp
_# p, G C) G! q+ x0 O! Z0 y4 w7 G
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: ) p% e0 A/ k$ r$ G* Z4 Q0 Q
c:\regsvr32.exe sample.ocx
" E! E% x1 V# P# R, n: d3 O ]" _$ H/ p, _" L' K
Regsvr32.exe 错误消息
. K4 ^ F- D1 [3 S
% V4 Z. s: m& q" U以下列表介绍了 RegSvr32 错误消息和可能的原因。 % f. W" P( e: A- ?1 `* ?6 @
& X0 K, h; [3 P& X7 H' D- z
Unrecognized flag:/invalid_flag
; S) s2 u- n) j: \% v% ^, p
: w. z# G4 I7 Z; }' j- g键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
# i" Q. K8 q$ ?4 a: m+ ~2 k. ^% \# W/ y# } |
No DLL name specified. 3 `- X0 S1 u) O0 P
% E; L1 v3 k9 t0 @5 O3 P$ P
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 + N! ~+ |9 J; Z T
. Q% Z8 m9 z- D1 Q/ [' ~4 R6 O; ZDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. \: }# V8 f8 \6 V# P
# n$ Y/ t) R7 N% i
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
& I4 M% V: b0 S4 `7 L- X$ L% _/ p
* p8 z; x$ l0 e) k+ N4 E0 z9 BDllname is not an executable file and no registration helper is registered for this file type.
1 u9 k) z8 e7 l+ k. k; j. G" S& O
" @' I% x* _: w1 b0 wDllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
* y: }, f/ j V; X
& }2 \9 p6 G& k& DDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. / X( o" d1 l& C. `, H$ M4 s
+ g' n5 k5 I- S* P* m( ]9 z
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
( _, f7 p, M8 z5 T" l
+ }$ L" b' j- h/ Q* J: A l: \Dllname is not self-registerable or a corrupted version is in memory. ! [- M* Y. h# Y8 {# B
& m$ i v: \: u6 V3 Q3 u
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
* t, V& @7 p7 Q/ J1 w1 C197155 如何终止孤立进程
( T% m/ o4 d+ E( Y7 t) k: U, E- n) [
; p- R8 C, L& `4 I# [7 POleInitialize failed (or OleUninitialize failed). ( P% y. o" A2 n! \. n
' Q9 k7 }4 D# u( R. B1 U+ Y _
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 e4 U" ^5 ~+ C7 b1 A& R: q- k
6 Z6 s' b% M8 s7 L
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485 2 x" o+ r5 H) T# R+ k7 C t
W( L5 C8 R5 u0 J" G
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
/ `/ A0 ~& H' f5 o% `
- M+ M8 i9 G b: y+ m$ bLoadLibrary("Dllname") failed.GetLastError returns 0x00000002 0 z9 v) I0 A u
* Q1 k6 L1 J# q* C& c( S2 ^
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。 8 g/ B! C3 _4 ]# D9 ^: G8 v
( m: i# K- x; t: X. ]: N9 W
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f O+ X) B6 L; I e( s
: e2 k9 Z9 D0 i" M) D. }* m- ]在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 . e3 u8 o% L. m! }; B% ~
3 z" R; _4 b" @( `! A2 }4 Y! X' vDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串 0 V$ {% W9 }- [- \
* B' Y7 _' q# X" _$ W在 Winerror.h 中搜索字符串。 * q3 b, B' |$ Z3 u
Regsvr32.exe 和依赖项 ! b& l* }9 L! o, j; M0 j
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 9 Z# N! R0 C5 g, L
# m4 p2 \+ H1 R7 g2 y
您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 % l2 Z0 n1 l3 x5 S- E
247024 Tools Included with the Microsoft Windows 98 Resource Kit |