对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。" c- P n, P8 Y7 A
: ^' s6 p; W/ Q0 x9 L
Regsvr32.exe 的用法
7 d( Z' T" s) s; |2 F% R! V. \- D( H
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname 0 \6 ]9 t4 a. ]) s3 u
, V3 F3 o, E7 c8 |( D" c9 B0 j
/u - Unregister server<BR/>
5 L" ~. V- t6 ?$ C, D /i - Call DllInstall passing it an optional [cmdline];
# D, c( Q9 o: `5 F when used with /u calls dll uninstall
: f3 o; Y5 c8 r% { /n - do not call DllRegisterServer; this option must
4 [% l8 p6 B0 q# B) n* N9 r be used with /i 7 I+ h: ?8 x" m c
$ n! N% T1 ?0 x1 \当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
( J4 V2 T1 ~5 c# X- A7 e$ ]http://msdn.microsoft.com/librar ... n32_error_codes.asp / E2 J3 e+ q* K% a( i( y
0 O( E. d o. x9 z0 f例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: % Q& z6 `6 L: ^3 V ]
c:\regsvr32.exe sample.ocx
* T- s& u. m* t
0 K2 Y$ H8 ~1 d: Y7 W) U* |9 g- ARegsvr32.exe 错误消息
) F* n! N' d2 ^1 p9 N P6 h5 D! W* p( z% f j$ w7 e
以下列表介绍了 RegSvr32 错误消息和可能的原因。
2 Q- H2 w" y ~9 e
5 w7 {$ [/ [$ nUnrecognized flag:/invalid_flag
) _2 u; m9 S% K% l! U- H' q( o( x* i( f' [. }/ p
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
+ q% _4 q# z+ E s. t d8 h2 s
# [+ v2 ]% p+ n( j& w/ B: ?No DLL name specified. 3 \9 Z3 c; ~) S* `
" w! n% U6 Z" o' Z8 B8 t2 N
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 0 V# H; c& o2 p) H; J
0 B& O* M4 f5 @) h, E' \" t" V
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
$ z- P" ]+ f$ G9 `, C2 t% {
+ w0 d% C: D% V+ H+ A+ y! BDllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 ! j2 h. g; q& ~+ F& o ?' ]
& }5 h4 k9 c3 q* Z( l- h9 K/ ]
Dllname is not an executable file and no registration helper is registered for this file type. # X2 |6 [) l* ]" H# j
* J7 L' F6 L9 |0 `% M# d+ xDllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
% X0 y9 N0 p2 m; I7 i) Z, Z% ~
% L3 g- _- T& R) w3 n/ m( y* zDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
* o. o. l: T: u7 W; P2 E* c
! Z: [. B7 g! ^) d6 }( O5 ODllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
+ v' c9 S* e: @6 s- M8 Q2 z* K
+ s; d$ V x( ^# b$ \3 H1 MDllname is not self-registerable or a corrupted version is in memory.
6 n2 P( j3 h0 C
X' H# U1 D( S1 K {+ |例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
% y7 a, k- h7 [3 E; v6 u+ W: l197155 如何终止孤立进程
4 d a1 t& x5 s, c2 `$ w
. _* g. n- [# s6 P4 f8 rOleInitialize failed (or OleUninitialize failed). 6 ~! ~' c! V' h5 O* w8 C0 K
6 S6 `. K- R% U) }3 G9 x5 wRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
- `/ A: {4 y# _! a5 u; u! R! B8 I# e3 B3 ^1 t9 W S( I/ C
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485 9 a( ^ D, _9 x& f
9 \$ l0 v) P" b; E2 j% b在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 8 ?! o w+ }& R( ~. I& M
& W8 F" l1 k$ A- \2 [& ]/ t8 S; r7 u
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002
* Z: Y6 z. I% B$ ?6 o# l
/ O: q0 A& E# ^1 e( v! r. w: q在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
4 I% M' j( A; R: s& M) f; U9 N
" }! p$ r$ u. M: p; ELoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
) y" s$ b/ ^, ~* H b; |& X* h5 s$ D
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
" k# K' u6 E( b; O W6 m: V% v. C( s9 |! O- ?/ @$ F" E( m" @! o
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
; ~2 f; P' h6 H7 J1 K- f+ n. n! @, \5 z' {8 ] g: c$ |8 b
在 Winerror.h 中搜索字符串。
3 A1 l4 u( x0 P QRegsvr32.exe 和依赖项 ( w5 v- j' x$ p# y* F
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 o, d! L0 H2 x) m: d Y: w- |
$ v, l1 a7 v8 W x6 B4 M2 k1 n您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
( D0 M9 ?2 q2 @ X9 c! \6 Q5 q% B247024 Tools Included with the Microsoft Windows 98 Resource Kit |