对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。
& I3 U! d" F! c( E& u, M# m* X- O
! X" q k i6 a9 h9 o( GRegsvr32.exe 的用法 . `0 m7 t7 l7 f7 X8 `: a
( \4 e6 J3 e2 w; d% \RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname
F, h' _$ s* Z
2 u- J* E! q/ [# w$ e3 @ /u - Unregister server<BR/>
4 m" {1 H$ S+ g) j. G /i - Call DllInstall passing it an optional [cmdline]; ' x) Z, Z4 O0 h3 X; a1 M
when used with /u calls dll uninstall * I+ V6 u+ ?1 z6 X3 Z
/n - do not call DllRegisterServer; this option must
8 r+ j% F$ X8 S! P0 \+ C- t be used with /i ' }" B, z, Z. j: {
7 w( V& P! m4 R) O8 n/ P当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: 5 `/ d4 L0 G% C l
http://msdn.microsoft.com/librar ... n32_error_codes.asp
$ s* W9 t x2 K; B/ N1 L0 X" y7 \9 G T8 `1 b6 a+ `+ i! o- F+ {# x
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: 2 [# f! B, r3 E: s2 C! J4 k
c:\regsvr32.exe sample.ocx 1 Z% L0 B; \) s8 C' y8 j
& [5 w5 Z7 _: ?
Regsvr32.exe 错误消息 8 L' v; [. r8 k; F1 X* I/ h
! V2 j w. q. w& z0 ]4 c1 l以下列表介绍了 RegSvr32 错误消息和可能的原因。 & D: i6 y' l3 x7 q( F
( e2 E* u# e' L: b7 |! ZUnrecognized flag:/invalid_flag 3 x S) e7 l9 C% p) K) s# c
7 q& w& @: F# T/ s/ `/ c
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 2 ~8 X2 }) A4 q, E
$ s6 q- k7 g8 [: X1 O( z9 fNo DLL name specified.
8 s) Z( p3 u) \, P5 p; |
4 ^, M$ p! j# j; _+ ~' i! N未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。
6 _7 t# i( `4 V6 t* N1 u8 T3 d: U2 T7 \5 ]% r
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
/ x2 a8 G4 @% \' u. G1 n F- E' ?$ X' D" K( p1 h$ U# c, M
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
, A/ I+ t" v: L- B% D6 x. a9 A' P
- V4 `1 M# g7 y# IDllname is not an executable file and no registration helper is registered for this file type.
- l- i$ A" Q9 `( c9 v7 \* }' G3 I& `7 \% Z4 x, n
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。 ; h3 ]( r' g( q' v/ K/ v, q
9 M% k4 \9 B7 M+ ~. P' o( j& jDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
/ N$ h( w& X0 i8 P; R5 R7 Y1 O9 p1 M0 I1 h% N3 I( _
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
& l* V, I" j# n" o& k" R, s# m2 g2 m0 W( F" u6 j* e" y
Dllname is not self-registerable or a corrupted version is in memory.
- w5 W4 p+ d1 S4 F+ h( m
1 d" {9 `9 f2 s# P例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
' s/ Q! M- [$ @7 y: b8 M197155 如何终止孤立进程 9 S% M" P4 q7 z$ W( J
) T. g/ Z0 J8 n* Y+ q) x- A
OleInitialize failed (or OleUninitialize failed). 8 s( D% m1 y' B; u: `4 K N. G" J
" U8 K f* F6 o" J5 o$ HRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 1 Z1 ^3 }6 P2 b9 H
2 }% e8 o/ R* @2 hLoadLibrary("Dllname") failed.GetlastError returns 0x00000485 2 H; t/ g' y( N7 l
6 n% J' [4 {$ ` l' f/ p在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 9 I$ j. F0 {1 S! b) h" x
+ b6 G1 Y: j9 Y3 LLoadLibrary("Dllname") failed.GetLastError returns 0x00000002
& _" V3 B) i: Y6 R" j- g5 t0 j7 ~+ e* @6 C# X
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
* a* i3 f8 ~) [$ j, j1 }3 ^
& T7 j8 F" P8 I/ `; t" p- C; pLoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
- S8 Q" R) U, |2 p
0 l! A- x1 ^, f1 U在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 ( M; K+ A1 F0 k& I9 c
# q5 n) T1 b) `$ ]% e. D
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
: e' Y0 E9 Y0 ^8 M' z, W6 W3 m
! `! ?3 P3 z% ~! ]2 f在 Winerror.h 中搜索字符串。
, k( X* B( b* U5 P6 gRegsvr32.exe 和依赖项 4 i3 y8 |# L5 `5 ^& F8 `4 w
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 2 R: N0 K. b$ z$ r! [- `
$ s9 m& U9 k- m$ e* w; u您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
/ P( c( ?. ~: R" m5 _7 u |247024 Tools Included with the Microsoft Windows 98 Resource Kit |