对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。" ~# o; n# \# E3 ^% Z0 I1 B1 p/ c0 D
" ~& \1 s! Y2 D: m. \5 d
Regsvr32.exe 的用法
% K( ]7 T$ c% c8 B8 e9 M; d6 j+ w& w8 ~
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname 6 z+ G6 x1 h \6 D4 o# e" @4 h
7 F$ Q3 s5 {" x9 x8 |4 d
/u - Unregister server<BR/> 8 k6 M7 U( x" G1 ]
/i - Call DllInstall passing it an optional [cmdline];
& W$ w* _! x' H1 M% X3 m when used with /u calls dll uninstall
9 K' g: [& n0 ^' r+ i2 i, X; D /n - do not call DllRegisterServer; this option must : e! K7 T8 A, v7 U7 n( X1 Y# G% Z
be used with /i 3 z6 i7 C2 ?. k( [# w
( K# L+ z4 ]! [ F% j
当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
3 y, O! |6 K# D. n# j( O$ B: M, Ohttp://msdn.microsoft.com/librar ... n32_error_codes.asp
- |2 ~9 J0 X. r! J" a7 i
' m: a6 D3 ^- v& q. K例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
; |$ M# K) f- _, E; H/ W i0 Fc:\regsvr32.exe sample.ocx
' Z5 U4 y9 e, E) C+ i, w3 b% b0 o2 ?6 N/ |3 l% P
Regsvr32.exe 错误消息
# c9 Q: a7 Z# a% B2 ]3 U
: Z* X3 l% @- ?+ J以下列表介绍了 RegSvr32 错误消息和可能的原因。 # @7 ?/ l j: x4 i4 }5 v5 @4 w
& E" i7 S* I- |6 S0 D
Unrecognized flag:/invalid_flag * U; m7 ~7 C: i, m' {6 e
# m& h1 c* X) ~4 N# V; _( K, m键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
$ W4 `4 P5 f0 o7 B. z8 q5 f1 J$ J2 F$ k! f9 p8 M" ?
No DLL name specified.
+ W/ i/ |2 Q3 X$ w. I0 K7 a" q( Y" c
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 1 H. F7 Q* G4 I& M& j
+ h( f2 n3 r3 B, ^9 I, g1 Z' w
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
4 M' O8 ~: N! w1 A, s" a8 m* o# R: [
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 n T% h0 L% L" I' ~4 d
6 ?# W: F8 \' J6 n# L/ v! _* i+ x
Dllname is not an executable file and no registration helper is registered for this file type. + E& j) a2 N% p4 p3 U; W& t' Z) \
' G0 m0 J0 P% s! [$ p
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
# c, }$ N1 k3 A8 b: K" u- P: x ^/ C5 T a' U9 ~
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
1 A+ F1 M7 Q! Z) M7 U. L+ F# |1 I7 @( s6 `. B( V/ S1 n3 R
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
P; ^7 p( Q& u6 W
: V! ?! ^& R! ?, m" w& {' i+ [Dllname is not self-registerable or a corrupted version is in memory. % h3 d+ f5 Q8 j' R
2 U! R: U1 g* B/ i
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: ) F% |) o3 q' F7 s! V9 ]
197155 如何终止孤立进程
1 ~' Q4 X" a# O$ z& V6 Z8 \# M( A1 K0 q. @: t8 X' p- \
OleInitialize failed (or OleUninitialize failed).
( H: O. m. r& j- G1 y% t5 K8 r- X% ?. t3 C1 @ v. w9 ^9 L
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 6 o* o9 X$ s6 D/ ?" j- P Q4 C6 A, k
% Z7 d! j% S- ^1 W) iLoadLibrary("Dllname") failed.GetlastError returns 0x00000485 7 h% G0 F( J. |! e
6 P$ X P* J* F; d
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
5 Q, J% f* i% C' G& P! g# I' {1 T+ y/ e* K# B
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 0 Y @3 [: v9 ?0 F* W8 V
! _# J1 y a# f0 w6 _4 E' \3 u
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
Y& F' O2 o4 }6 F3 o Y, R( \: u- p
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
9 o8 Z% s: c; D4 {8 I
& K$ a0 f0 X1 D s在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 " Z/ m: h3 A0 k( \9 @0 H
, I3 \9 V3 T) p3 n
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串 ' N& ^- A1 G: B' K, k9 Q% n
- i2 \( w A% q! S- f
在 Winerror.h 中搜索字符串。
( [* ^3 q \8 Y# wRegsvr32.exe 和依赖项
9 ?9 M( w/ N; S+ y; S8 \RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。
2 I. M K. Z- j2 D, c
$ Z0 s/ u) U2 H' b7 t, v您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 - T1 {1 F2 P; f
247024 Tools Included with the Microsoft Windows 98 Resource Kit |