对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。# n6 n7 s5 C/ g+ @2 {5 d( r" ]$ H& k
W! Z# J8 x$ D4 _8 p' p. W
Regsvr32.exe 的用法 8 B6 i! n5 e. H B9 L4 E
4 Y( w# G9 s M3 E7 n0 { }# d+ }
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname - Y/ n0 b% y/ E$ u
3 f, S6 g- d/ c8 C/ k& s" o5 | /u - Unregister server<BR/> $ B/ m6 {9 w7 b' N) |9 l
/i - Call DllInstall passing it an optional [cmdline]; ( [5 u- t0 h- ~
when used with /u calls dll uninstall
+ x: F% W$ o6 ] /n - do not call DllRegisterServer; this option must
) r# |, x/ H$ @# l( e. _ be used with /i
3 c+ ~2 X3 D8 h: Q; X/ \$ _) p# E: r8 [/ U8 m. F! A
当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: 5 ~% M1 m9 o; Q' I" R' z( U J
http://msdn.microsoft.com/librar ... n32_error_codes.asp ) f7 Z, o$ F0 B5 ^( o
& l5 H G% }" Y例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
7 X' G: n8 B6 ^; U" i2 mc:\regsvr32.exe sample.ocx 6 q& l% A; N1 G, J. F0 y+ c
& \, x# E4 E8 @4 x4 d3 C. E+ e! Z
Regsvr32.exe 错误消息
5 c( w+ M5 N E d0 o' E( o& t8 V8 B3 I; B# d
以下列表介绍了 RegSvr32 错误消息和可能的原因。
+ F( A7 e& S9 j5 L. [; w" {9 O2 S9 A+ }! ?9 l" N k& q
Unrecognized flag:/invalid_flag . L# X: w \ ?
! Z2 s a( a6 z4 ?; S
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 G( M; F3 K+ X3 l1 h: C1 z
6 G: H( w0 t, F. }$ RNo DLL name specified.
1 L) k8 k5 Y# u( e8 y, T
) W4 ?: q% h2 a5 x未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。
3 U. @( x9 p& ~" Q5 V1 Q I5 Q9 V1 _7 C2 H$ ~6 [4 E
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
+ @: b3 q( {% [5 d& m7 T
. Z% @/ J3 }' c$ F, e8 x; }Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
0 N8 P( [! g! N+ K. F
) F3 V- [( c8 l, g" @Dllname is not an executable file and no registration helper is registered for this file type.
. e2 s9 s8 B9 g( w/ G
: d( `( Q: ~" U; x. p; RDllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。 $ G- w& ?2 g) V. f
% l9 W' E; C, x8 k I! IDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
6 I9 D4 v% M. A4 ]7 r1 \9 P: w. g' |8 @& o7 S$ |5 b
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。 , O9 P, w |) {6 i C2 c
: |! ]' @1 W" i( [Dllname is not self-registerable or a corrupted version is in memory.
2 y% c8 P0 s% _% |9 c& w9 u" a$ F
+ v4 \/ a7 V M& ]% o例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: ; b ?$ ]. _+ C' s" e
197155 如何终止孤立进程
# E& s) o' o+ s
\: q T4 W* G, @' W3 J) XOleInitialize failed (or OleUninitialize failed). / J- Z: O9 O+ t5 N/ m9 ]
6 x/ u& u. g5 @: [7 K! x
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
3 _0 Z6 W/ U' l- d5 U% k
5 q0 Z- C# r- m$ x: [3 ?4 W7 ?' sLoadLibrary("Dllname") failed.GetlastError returns 0x00000485 & I/ w& \- a0 V" _1 @
6 q+ b+ A l, P2 m在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 ; t" z2 \% S9 L m. @
# _) p# ?2 d" T. s4 Z) G5 J2 N& i- R: h" mLoadLibrary("Dllname") failed.GetLastError returns 0x00000002
/ V$ m' z/ `3 T6 {
" f$ D; H3 |' Z. I0 d, o在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
g; M. A. X& d/ U7 R) }; R4 \3 S1 V8 n! ]: z3 s
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f / [ c# }9 j/ S; l, X" W- Z
/ j2 Q) w/ U" G- D在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
9 E2 N& G! c5 w- R$ m0 |1 h& j9 f7 D7 j8 z: f
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串 - W7 a+ c; I; G5 o1 ^ d2 h1 }
% v" e& t9 ~# Z% q
在 Winerror.h 中搜索字符串。
8 _' v( f. \3 `6 q9 L$ ]4 B BRegsvr32.exe 和依赖项
3 F8 L% }' m3 V' m% DRegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 ' n, h: r1 P' v$ H
" `: J, g4 W/ m/ P& P" X5 o您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
7 j4 w1 L' J4 [, @6 M& e247024 Tools Included with the Microsoft Windows 98 Resource Kit |