对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。8 m4 ~: a. l2 |% x% }/ h& n4 q
* }; A; w0 \1 q9 F0 r* j( x+ VRegsvr32.exe 的用法 e( b \; e, J, G+ y
" `& E& @/ m% d0 _
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname
2 V4 P& ?# ]9 m+ ]5 c0 ^" y, X" B
; U* g0 D- K e8 N9 | /u - Unregister server<BR/> # S u6 J8 [. a9 k0 ]' _* r4 |
/i - Call DllInstall passing it an optional [cmdline];
0 y1 I+ h0 e1 s' z when used with /u calls dll uninstall
9 ^7 b! o' _. b# H /n - do not call DllRegisterServer; this option must
! Z6 m+ j( z! u6 p/ C2 Z9 G be used with /i 0 n( @2 l- D9 d) G. V, t/ K
# @3 ?7 m7 O9 s, u' |& v' r* f5 v. ?7 |6 R当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: # H5 U2 m" }9 @. @0 D. Z2 `
http://msdn.microsoft.com/librar ... n32_error_codes.asp ! M: n- x# p3 N. b4 f
, e( R q/ P2 ]" C3 b9 T例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: " p- r# n% [0 m9 [, f' U
c:\regsvr32.exe sample.ocx
, H1 p6 Z9 g+ f! a0 A" c/ |! {' V0 G$ f6 y3 @
Regsvr32.exe 错误消息 : M( {+ H8 E' }, x+ L6 r! p
& e3 \% b3 d$ ?! I | |
以下列表介绍了 RegSvr32 错误消息和可能的原因。
2 A" F5 W0 r! B3 [
0 P7 M5 w3 I2 E" z5 fUnrecognized flag:/invalid_flag 1 E4 v7 ?$ G3 G7 T0 m$ [! L8 Z* I
; j" q4 p: |. u H& O
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
- V( T8 W3 K7 q& `
% H: [0 d! p% v/ bNo DLL name specified.
& C0 R1 [7 N5 c( @2 x/ j$ y) ?/ k: i7 _
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。
. Z1 v% Q+ }( U: O
f1 a/ g# k1 o- V/ a1 i7 lDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. + m$ k2 ?8 Q3 O2 N0 c0 ? z- B, Y
7 ]7 _* o) {! c! v* V5 v9 `Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 4 P) `' U, h5 E/ d9 E
# n8 C; Y$ `0 [9 L9 [
Dllname is not an executable file and no registration helper is registered for this file type.
' e2 }$ O! e4 X& G$ y8 p' F% z# N/ @( Z
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
1 W0 F- x* p: o2 n0 W& [
: \; X# P* b# |' iDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
1 A1 t2 ^( ^/ f$ m b( @
; _; S! z9 j6 I: z1 n' rDllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
g9 @9 c5 x4 A! F& ]- R Y- Z! }7 Q- y: d) n8 V2 T
Dllname is not self-registerable or a corrupted version is in memory. , }2 T! z0 z6 V* K+ B: J4 \$ G% z$ D
# c) q" ]5 [5 |1 U! w8 y
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
) k1 x. J8 j* e: e197155 如何终止孤立进程 $ l9 ?1 R6 x6 e: W$ X5 E
4 ?2 |# r* Q( S5 C, o; X( wOleInitialize failed (or OleUninitialize failed).
' h0 k! w% Q% _9 x: y$ G! o# u) B7 x8 Q8 A) C* ]1 P
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 - |3 I h0 H$ |- i# u
; E: g Z( {) p1 ALoadLibrary("Dllname") failed.GetlastError returns 0x00000485
4 D! s; G! H/ h+ J. V, A# b
; R3 R$ ?9 w% @% ^2 s5 i3 h8 S在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
1 X9 _* v( c6 Y2 P' r T R$ ^5 E5 e" g2 M0 Z. \
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 / O$ n R3 {9 [% P
& d+ o7 y) D5 b" X% q在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。 & u& a- B/ a% U" M- d; C2 G
- }, @- Y9 Z P" F- \' V, aLoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f % a, V* N" k, u6 _- B6 r5 g
: q3 }) m1 ~% R: D6 @3 R在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 . M% w$ o/ D/ o% V) r
( Q" s7 Q5 f: `' ZDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
0 }6 `% c+ I2 ~* q4 l9 p
t, }7 C, ~" w1 w0 x! @6 D在 Winerror.h 中搜索字符串。
$ [# O1 o& m7 U/ J; \Regsvr32.exe 和依赖项
/ ~1 d: U) g! ^RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 6 b3 [ O" z( G& @3 L+ d7 m
7 s" _% j6 y' W4 J( K2 j5 J
您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
% ?# j3 }3 X5 U: g$ |- L247024 Tools Included with the Microsoft Windows 98 Resource Kit |