对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。7 F4 c2 q! [! L& n2 L
, m$ {7 J' V8 T6 P2 W+ J4 oRegsvr32.exe 的用法 . O+ o, @0 ^% _5 m9 h+ K5 Q
P, r1 d4 i6 @% `& c& r* A! bRegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname
$ b9 r( g% e4 t9 x5 V# f9 u7 _( z9 x* a+ g
/u - Unregister server<BR/>
$ T) q& \) x% e /i - Call DllInstall passing it an optional [cmdline]; " l( l- V8 a, |1 a$ |. N
when used with /u calls dll uninstall
7 n U$ n5 Q g- N* k, b /n - do not call DllRegisterServer; this option must 9 N7 E+ G( [+ L. z) N4 G$ _$ c F
be used with /i + @: q0 c& _' l& N. c* Y2 t; y
/ E9 w4 ]0 \6 g; G' W, o3 j. P3 b当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
- x \* j9 ?8 W6 [http://msdn.microsoft.com/librar ... n32_error_codes.asp 5 E) x! D! u! W, M( z% K
) N7 Y7 h7 H, {; m I- i# d
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: 0 p3 t$ X4 R6 y/ q9 V; S
c:\regsvr32.exe sample.ocx ' B$ n/ x* E$ G, ~, y' D; _
/ a- h, T' S, i- p6 n3 m- s
Regsvr32.exe 错误消息
. F6 X' |. E, l6 a- v( O& e& ]3 r$ L1 b/ X4 D1 |
以下列表介绍了 RegSvr32 错误消息和可能的原因。 3 k6 A. p# ~$ ?% k* h+ y+ r* B
( E- G+ ?5 r2 u. R4 B( N) r
Unrecognized flag:/invalid_flag
p% u* R* [* P- Y/ u
1 o: y$ {+ y# F键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 9 V3 G. u) X. N5 s! a7 j& ^1 ~, Y
$ g( f. y. M/ F8 O7 UNo DLL name specified. . \& n6 h- W. W# M) c7 B( r! x& U" L
* X0 x. x% f" x9 Z& b, W( |9 {. U未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 & T3 D% g9 |: N1 _6 w* G q {. ]
3 i7 Z6 ?) Q' ^% F5 WDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
! [% H, J4 M* z8 K5 d! y) w2 u2 n4 O9 y1 O
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 ; `( s: w5 O6 b# g* @8 ]0 ^
. H3 |2 L# P2 f6 X8 S
Dllname is not an executable file and no registration helper is registered for this file type.
% a+ v4 W6 J1 y/ C, L: I
+ [0 U& K* ^' ?6 k7 nDllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。 * g& r2 n6 `0 Y8 W1 T8 R7 ~
; B; a! |& J9 I @Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
E4 v1 V& Z* k2 a9 C- d3 I) w* Z% a* @7 W
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。 , @! [( Y s) q1 v k% E
% W5 A3 s# E& b; C2 k1 K
Dllname is not self-registerable or a corrupted version is in memory. ' U, n5 G% R# M; Y7 L6 I5 a% N
9 R1 h# y2 S0 o7 |5 G+ A8 r
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
8 Z" J. p. w6 B# w5 z% l197155 如何终止孤立进程 3 l7 j$ Y, y" F- d/ T \
: r: {! e' i3 V* F9 P; iOleInitialize failed (or OleUninitialize failed). 8 F- s; W, n9 B7 p; O8 c
. l2 ~( a% g0 E3 \# z
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
+ ?% j' T% v1 P. @+ j+ T4 w
( X9 e! e. M5 m. ~1 _$ DLoadLibrary("Dllname") failed.GetlastError returns 0x00000485
" w0 {5 K1 q6 `7 p, ~8 m! e
3 a; z C) H* S2 @在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 " ~8 F1 `5 g1 p e) A& F+ x" b
: f3 s- i8 l! N' U QLoadLibrary("Dllname") failed.GetLastError returns 0x00000002
8 c) y) d# {4 \" v
- p- k6 U% X5 r5 P在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。 , J$ ]& J' t1 O) F
! z% C# _+ V8 ?9 a! [) t8 b5 s3 ?
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
' w( p# M6 o' ?0 D; H) x; ^0 O2 t! V' F7 B" S! ~/ H+ p
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 8 i) q1 y# u, H( i& F4 l
8 |3 e# u1 x s" W wDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
2 \; H* q+ y3 T# d! S5 @
% C5 j; X" R% p+ h1 S1 A# P在 Winerror.h 中搜索字符串。 6 ]: W6 _' G' C' P9 F
Regsvr32.exe 和依赖项 # i) o( y$ f7 e0 j( Q. x9 B- @+ k5 X
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。
7 t* B; l0 B, p* f2 X! ?, H3 i9 O# q. U5 Q. I8 e) a
您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 s3 }7 D9 S9 V6 n. H/ W* M
247024 Tools Included with the Microsoft Windows 98 Resource Kit |