对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。8 w5 u7 S W/ t6 d4 V
, N8 _ [6 O& `9 r
Regsvr32.exe 的用法 # W5 M4 e% R; E5 Y( ?! q0 Z* c. c) N
' ~6 V0 H" h3 p3 p9 qRegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname , ]9 Q& C* t8 T0 {8 }8 Z, P
! |5 I2 v: o' S& K4 r. e' Y% @ /u - Unregister server<BR/> 8 H0 T9 g# W$ c" d1 o' l/ I9 [
/i - Call DllInstall passing it an optional [cmdline]; 7 Q* i7 J' d* a6 {( l
when used with /u calls dll uninstall + V2 `, p. q, R; G8 f
/n - do not call DllRegisterServer; this option must R+ v' I4 a' y
be used with /i 9 D/ w5 m: w5 s$ {
. N, b! t' ~0 V
当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: 7 a" a. d/ E, t' x$ D( k) n# V
http://msdn.microsoft.com/librar ... n32_error_codes.asp
: N. ` C: H2 z. t( \/ S5 T7 c9 d2 i# i* f" @- G/ q
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: 4 \3 z, n3 g' z+ G9 u
c:\regsvr32.exe sample.ocx
$ q9 l ?/ N1 S" E* }. [! P- x5 \5 ?+ b# F( W
Regsvr32.exe 错误消息 3 O7 H( K2 z+ M
2 h S( T# S9 Y3 `, e
以下列表介绍了 RegSvr32 错误消息和可能的原因。
1 b) Z* L- x) G3 y6 n9 [1 {! c9 t0 W; b
Unrecognized flag:/invalid_flag % s2 Y6 Q& b: F+ f; z; p
. P6 Z6 K2 F% G6 |, i; \键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 0 L6 `1 Z. M* n5 m4 H% K. A T
4 C8 |4 O" ?+ u! V/ Y6 |+ P; n& T
No DLL name specified. " ?( q, @3 N W. G0 Y3 M
7 y; I5 k9 \ O, B
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 7 M h- \0 k3 _0 R: A9 J
) x) z0 g! u7 K- }) E! o: CDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
" i3 F3 f% I6 H* U) L9 ]
- {$ S: z& w& VDllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 / n8 B5 ?; p8 q- o
( R7 U& b, V3 e5 D* C/ \: P
Dllname is not an executable file and no registration helper is registered for this file type.
) Q/ h1 H+ q% J4 w
) D" U5 S% y1 j. Q, {Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
4 |4 P# {4 e" H; s
, m/ D- a0 K8 @2 F1 W: z2 e. ]* PDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
& q7 [. z7 s: Y0 h5 T7 f! \5 ]% C8 p) U4 R3 K" L( a. A( Q
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
# c9 B* _/ w7 z: G: K) t% R& Z- a$ w z
Dllname is not self-registerable or a corrupted version is in memory. 5 t( B( E& w( i Z. R; a* z
" ?4 c1 H. c7 ]3 i4 m8 z" l$ b例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: e9 D% ~- D. p3 S1 x, Z& l$ `' K8 y
197155 如何终止孤立进程 : O; x, ]$ o8 I! F! J- j
8 u7 ~. d% I4 EOleInitialize failed (or OleUninitialize failed). . M3 ]; v& s' [$ F
& I/ z+ I) u4 q. H3 R6 p1 L0 ?Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
2 L( i; p7 B& R u6 y9 m% y1 Q% }4 K; L- ~) M, h# o7 _3 R) a
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485 ) B7 }& m3 W7 \, D( B E
8 T3 P1 B. R/ g. f% T- k
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
* ^+ e c& N/ D
8 _9 ~! F1 w" b6 ZLoadLibrary("Dllname") failed.GetLastError returns 0x00000002
, l0 G$ A8 ?; \9 {
+ X/ |" B X* ?; k5 ^在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
! E8 K6 |* P2 w8 @4 p2 n4 p: L% f4 q: D* a4 r. F* H2 s" o! R
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f & ]. C' l: k9 \' R4 ^3 A: u
2 ^; l7 h _% {6 R
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 , _. H: P; ^+ d: s4 f& X9 p
" E: y- Z0 h1 t4 @% @; P
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
6 Q2 Q+ G6 N9 t% r2 M
! ]6 \5 v8 I7 d' i在 Winerror.h 中搜索字符串。
8 G+ S, P0 f! \0 ^' z! xRegsvr32.exe 和依赖项
& N% ] _7 e4 U1 h) URegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 8 W4 ?9 V. @% B. }
- e6 F2 e# b* S- O
您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 6 E0 }7 }/ c8 x t' g+ `; D
247024 Tools Included with the Microsoft Windows 98 Resource Kit |