对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。1 V' H9 ^. c# y) K$ c- p( k. U
$ K3 N/ b% w# T. }Regsvr32.exe 的用法 5 Y/ v. P8 q( `/ E. _
) }4 T# v. l- G' e
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname
0 M8 Y7 `$ n8 W9 W0 t+ N( |1 J" e- F
/u - Unregister server<BR/>
1 Y, T2 v& ]: A- ?5 K; h /i - Call DllInstall passing it an optional [cmdline]; . L7 y0 ^0 `7 p" x6 Q( W8 @
when used with /u calls dll uninstall $ { f, F7 Z" N' G
/n - do not call DllRegisterServer; this option must
( r% Z& ]( d% G8 p6 k4 P' k! @+ g be used with /i
( I" V5 i/ [* |" M9 c
* ~0 I; H7 U7 L% S$ l当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: 6 f" l- v9 T( {3 @; W/ ^
http://msdn.microsoft.com/librar ... n32_error_codes.asp - @4 c2 i% s% j4 }9 K$ @2 ~
; I2 X6 }/ J0 t4 ^例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: $ g2 m& V: X! U9 K# C$ {. n
c:\regsvr32.exe sample.ocx
) D4 a$ a( k* x. }' r3 p
& s: \* i8 D9 f7 X IRegsvr32.exe 错误消息 . i8 q/ B# y8 L+ p6 Q7 z$ r# {( I
+ M$ o9 j0 _1 u6 K
以下列表介绍了 RegSvr32 错误消息和可能的原因。
! Q0 I8 [5 j8 H% u+ K3 b! o [3 Q8 Z% W
Unrecognized flag:/invalid_flag 8 D4 a$ l' z" y- H7 l1 d
- Y n+ W# Q) M: b Y* k
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 6 H5 C+ l% N" s& t$ d q
4 g" ~% B" c' y f
No DLL name specified. 1 X: p) a. J Y' b8 l
8 J( j# _, ^" n/ u未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 D- y1 Q" B) r& a9 Q3 L
& H! K6 M2 Z3 ]+ \Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
- o, ^: p* [+ w+ l4 h1 _' [+ S+ b, b3 q) L3 u# n4 x' t
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 9 ]' k! d: h0 r6 F8 Q
' f0 G8 o7 d5 R1 y6 P( I1 DDllname is not an executable file and no registration helper is registered for this file type.
6 `' [2 ~7 @3 `
$ K$ a+ P' y, b; c9 |Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
9 t$ Q5 R, l+ E) R4 m% {" X: k. l) z# G7 t% g1 |
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
) F- n8 [! u- N, l$ B! @! m9 H3 b. t, V, r' p5 K0 c
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。 1 E- Z* X" H! n, v* O
% }0 f& w3 }; _: q- \1 `& rDllname is not self-registerable or a corrupted version is in memory. " G. I8 E3 `6 y" V' B% f( L8 ]
8 Q! Q0 e; Z: z+ R! L x例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
" C: w/ e2 @0 t197155 如何终止孤立进程 % q5 r! E5 V: f2 Y0 x* o
& j* c; P' ?9 b- w8 MOleInitialize failed (or OleUninitialize failed).
7 U; K3 Y, I1 t. `0 S1 B) L; {7 V, k; }; }
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 6 t% r% l5 R6 H1 d9 Z3 B7 x. u9 L
: U! @8 A2 Y) S$ \$ x/ v2 XLoadLibrary("Dllname") failed.GetlastError returns 0x00000485 ; z+ u: ]' Z( C* F) Y: y5 v
9 K) w" A' Z9 y" v在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 . W: z; i3 g( S3 o |9 F% X. J, t
) k7 ^/ i+ O V2 P
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 ' V* w) b e% r. y/ M1 m
$ [) a5 O6 Q7 c在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。 5 r7 e/ N2 u* h, M" m! T5 F
+ Z7 \1 Y( M; `) b5 V/ J# N" l
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
4 A) o. D- Q0 G( N, b. _3 U; V* x' e- X0 Z: h. G
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
& G. |4 k, p9 r
8 [) j% t8 u( Q8 x- MDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
/ i m/ O o7 d% _9 |! L4 j Q2 A0 { E" S7 \
在 Winerror.h 中搜索字符串。 ! S1 m' C# M* V, i; H
Regsvr32.exe 和依赖项 , G0 q# C+ g1 x+ f
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 4 k4 X' {' ], [7 z
4 S4 c/ e& Y7 C- t! u您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 , Q( l1 t, m& j! I6 `' R
247024 Tools Included with the Microsoft Windows 98 Resource Kit |