对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。8 G( J) c3 M7 L* S5 [
8 s0 p: m- @1 L) d! x
Regsvr32.exe 的用法
! u/ d$ L- }/ b# R/ F) W0 j( e+ `" e9 h( U6 f% G
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname ( M2 d" v$ @; P
3 T' N- \, a: K6 O6 i! i /u - Unregister server<BR/>
}/ |9 B7 z8 l& l9 U /i - Call DllInstall passing it an optional [cmdline]; 1 R* F0 j7 V( W3 z: l) Q
when used with /u calls dll uninstall
' v- O; d) l4 X5 n U4 D /n - do not call DllRegisterServer; this option must $ s1 g2 l3 A& ~* G& B! f
be used with /i ( R* g3 X5 P5 M% y0 u% R/ @3 b* ?. @ [
9 S: S+ h7 `$ t2 @8 X% l1 W当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
; F! H! }4 k! E- ]http://msdn.microsoft.com/librar ... n32_error_codes.asp 0 J; K) E$ F/ @. D
2 E' g0 D$ [# F: S# j
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
1 P9 b. [: [& I. h7 U4 L$ sc:\regsvr32.exe sample.ocx 4 q# q/ S% f) m6 ~+ L W
! F+ \4 b0 E' n# O- @6 T
Regsvr32.exe 错误消息
' M X6 x4 Y" o; N! O& `% W0 {8 V" C
以下列表介绍了 RegSvr32 错误消息和可能的原因。
! E% j: a! u- @4 D% Q4 U5 L8 A% @6 o
) |/ C7 }: T6 ^( s8 iUnrecognized flag:/invalid_flag
$ L7 Y. n; u' D2 P6 R1 A F
' t; M+ G0 T7 P2 A, o$ o键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
1 A) z. }. \6 E; D. ]/ ], l+ Q
7 Z8 D% f, o5 B: ?1 [$ L z! PNo DLL name specified.
) K4 m% ~' j6 T8 U9 y/ `5 O+ D5 W! K7 {- W8 W% i. O
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。
# K. C1 ]/ U0 B2 Y1 h# T: E3 |( v, |) _8 V7 l
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
1 ?2 y- U, ]9 Q, v" e8 z* R' d. z0 L: s+ s
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 - s# N3 e) |" P
, Y$ K0 G3 B5 l# { h
Dllname is not an executable file and no registration helper is registered for this file type. + \1 s6 u5 r6 v% `; R' ?
U7 M: ?5 T# O/ n$ ]' c0 ?Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
& \* a9 d3 z7 F( c' P2 d/ t% {
2 l2 S6 H$ W5 K, iDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. u* k$ _* D# P2 F8 p. Q; n
- F5 g' d! C8 K+ E. e
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。 * B: W( m4 B- d
( T2 p& D+ p6 [9 _2 `, {
Dllname is not self-registerable or a corrupted version is in memory.
0 T7 _: _- x. I; A! r/ K4 ~$ X% p/ z0 [1 @6 K, ^' H) q% G
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: 4 S2 p9 y) e. K j& W
197155 如何终止孤立进程
6 [5 Z: V' m y4 l8 }& y
+ g! O; }4 e7 z/ A! gOleInitialize failed (or OleUninitialize failed).
/ L( t! [: l& J. W9 O% c) g/ ~1 p
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
" D/ }" c0 Y( d: a" C# I9 H" G* I" {3 a$ h
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485
7 |) W, H6 P9 N- {* {
* A9 o8 m) A3 \. W4 j8 J" ?在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 9 h$ q' b9 \4 a/ W2 F. u
7 u* d' G* u7 N7 L
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 : e# ~# k: G: z( z% x
6 O( I _- x( j' G* L9 _; h
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。 ) [$ h4 L8 }) R- Y# @& [1 c1 l
4 w4 V# s- x9 U
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f ; Z m! h( N4 I, q" E4 h
+ V6 P' q# w& b' x ^/ B, S在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 2 ]) i$ r. `; N8 i. ?) {8 d
8 w1 @0 z8 B# m. T: e
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
% u Z: z2 @) X- V0 Y0 r, {2 c9 [. d* y! A' j6 K2 L
在 Winerror.h 中搜索字符串。 g$ ]+ d) W# U |
Regsvr32.exe 和依赖项
$ U. g9 ?+ H; n% e% B7 c }RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。
7 ~7 u( s2 [; J4 a* Y: U
6 h+ A0 D, ?8 Y# t* W% ^# J3 _您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 5 A( E6 x6 Q# V$ |+ q8 k
247024 Tools Included with the Microsoft Windows 98 Resource Kit |