对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。
2 ^% R) h9 M, P$ o- X( U
, c; _' E+ R" X2 t9 A( M& zRegsvr32.exe 的用法 5 W( u' x+ p& d. `& P9 @9 {7 E
. A2 D; M3 i5 HRegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname ) e) K# p. U1 S) { C8 @
& E$ Q. n8 R* h& x; ?
/u - Unregister server<BR/> ) a! l* F& U* ]& n
/i - Call DllInstall passing it an optional [cmdline]; 0 f* F# S ^5 d; m8 }
when used with /u calls dll uninstall
* f" \' p3 X" @* ?* j/ J4 Q2 D /n - do not call DllRegisterServer; this option must & n [ e! b5 I! O. o3 o3 W7 L( A
be used with /i , O# c7 v# |! f1 c [8 d
( M$ `$ p. F8 u L$ Q2 z; c当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: 6 Y2 {' z- k$ U5 b9 e
http://msdn.microsoft.com/librar ... n32_error_codes.asp
7 R+ _4 g) i6 W2 v+ [- u4 E* i8 W- m' S! i! W
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: 2 v. b& R" r( s3 J: F* `
c:\regsvr32.exe sample.ocx
' j+ e+ e& _5 Q* x
( H4 D* H) H5 \% D% zRegsvr32.exe 错误消息 & A% R6 K: u2 ~+ g$ M; `
/ C, d4 o1 o7 V5 ?; R o: X0 H# s
以下列表介绍了 RegSvr32 错误消息和可能的原因。
* E, G! \, U4 J( s3 { r+ f& Z
, t, J$ l" j& @$ uUnrecognized flag:/invalid_flag
2 U7 S% w! ~, w8 a9 [. J& [% g9 B, B2 k8 v
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 ' S& Q1 N1 r" x. k: D9 \: i1 a
. d5 h# z3 o# r3 G" P# n# jNo DLL name specified. ) P- f0 T5 N$ Z$ j% \1 E+ U) u+ S
' x& Q( g& a% m2 T) Y' w7 @" E未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。
8 x) s7 D3 e& b; c8 S* X
7 i4 G5 R, v6 I( NDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. ! H- `: L8 k2 Y% I" Q! e7 t
4 M% Y" C) p' A) KDllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 4 X* P3 k2 z" b' Q( h. ^6 `
9 H/ t% W3 x1 a1 ^" nDllname is not an executable file and no registration helper is registered for this file type. / h: s- g4 \7 S& }
, u, a6 i, d6 }1 Q$ z7 T
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
' v, N: F( i/ ~
9 ]7 U; _9 U4 Z- S" O3 \2 R, V/ LDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
$ V6 @% a K$ F, U3 W' K* b/ d- U' ~1 Z7 c
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。 0 E6 X- J3 c/ q- g& H* e6 V
# D2 z0 |5 E8 K3 c: ^) Z7 ?) r5 QDllname is not self-registerable or a corrupted version is in memory.
* F/ p& w1 T/ ?- ]1 z
' w! m u: r: f H2 B例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: ; c) i% J/ ^+ i, k5 ~8 M* t; |
197155 如何终止孤立进程
; q3 p! T1 i" y' F! p& \
4 I) P) ^( p) g" h; G2 [OleInitialize failed (or OleUninitialize failed).
: q: t9 X" J( D# W# T4 P `! I% T* }4 H. ^) W
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
7 C6 j- `, d# A M x/ U/ k6 N2 I. B, J% }
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485 7 q. _6 ]5 I5 s @; i
" e- _1 M7 w) s+ ?& {9 ]
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 , ~0 z; Q, z0 k& {
b9 J! n; z3 K
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002
$ ?% M0 e0 b; C% d
2 K5 b/ ?7 ]: N7 v0 |) t在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。 ' W2 n. v3 ?" Y# }8 s
# G2 x0 B( _+ H: ^0 a; q0 j
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f 9 e. x. a3 n4 V% a7 A3 g
' F+ ] k g+ C9 u3 |- w1 d) @在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 6 a, i2 |6 x' C2 y
4 z- E! q0 l2 F5 \DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
) r* y- O# r( b9 q! N% V% n- D; O( z: {5 e: _7 C+ Q
在 Winerror.h 中搜索字符串。
S5 h8 q% w2 B6 \; G+ |# Z# c' }Regsvr32.exe 和依赖项
! E5 }2 S" P- X$ O. m" QRegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 ; L- @* _2 U- I+ F& Y7 l
: ~" n4 S% I. R+ T$ I您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 5 V/ P) D: C b; J: f5 M9 ]
247024 Tools Included with the Microsoft Windows 98 Resource Kit |