对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。
, ?. _% Y8 K2 J/ j8 b$ J2 i8 t+ b- y8 G5 B4 S3 D
Regsvr32.exe 的用法 0 d4 W6 h4 D, e8 c. s% o
. N7 P8 ~5 Z4 H! uRegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname
3 D1 U' R3 A/ W" _' X
4 h6 W" m8 @2 @% J( X2 P /u - Unregister server<BR/>
; p) {+ l2 ~& M /i - Call DllInstall passing it an optional [cmdline]; / m; {( u1 z. s c Q8 _1 K
when used with /u calls dll uninstall
7 {& ?/ d1 B x S7 e1 L# a# U" U1 ? /n - do not call DllRegisterServer; this option must " Q3 I! b- A: J1 [
be used with /i
2 ?9 Y1 |+ [; b! I0 e3 a2 _$ C5 ? D( N3 ]9 P
当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
0 m0 l6 c) B. C; [; dhttp://msdn.microsoft.com/librar ... n32_error_codes.asp 1 E$ [0 B+ `- ~, i1 E; n/ k+ R
J# q0 I5 N! S8 `: v例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: W" q" |& o) v- \# p
c:\regsvr32.exe sample.ocx
0 L8 }; s/ m0 W/ L2 ]$ M# y
$ D! h/ z3 I: q$ rRegsvr32.exe 错误消息 / i( a" e' ` R- ~0 F8 H% J; b
5 t, n5 `& f) @$ V, A* I. G
以下列表介绍了 RegSvr32 错误消息和可能的原因。
7 u! O3 Z b$ l( }0 E3 P; t8 h5 h$ U0 ]
Unrecognized flag:/invalid_flag " y+ Q5 e8 A/ y5 {
3 R, s: P- l- X/ f+ P' h' u键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 ) y3 ?) N* }+ X! Z) K
% R1 G7 Y1 Y' m1 c: H% I( D, ANo DLL name specified.
! V1 j* j: H+ Q1 k; k
0 C: p. c: g: J+ o0 L3 Q: `: g未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。
# |7 S$ p/ o$ A( M8 Z1 m8 _. B# ^- b# C+ ?) V2 E
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
4 F2 |0 u7 F/ B$ b% v; m
* m* w* B% n" R/ P8 _Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 7 e, y8 E( x( P8 `: {+ U
" X# b: x- q4 }* P6 G) s
Dllname is not an executable file and no registration helper is registered for this file type.
$ h! X5 {& r- p% K
2 Y( [8 q5 a! X' o( g$ mDllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。 9 r3 {1 `; A7 ^0 S2 k+ Q/ k `
) G; t4 |& ]' f6 q3 {Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. % R# ~4 k) |" D/ y' c
" F( I0 e! Z% h* _2 y- YDllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
! \# J- Q X, i1 d' Y' B8 d" u( u6 o( \& y+ }
Dllname is not self-registerable or a corrupted version is in memory.
* T z+ r. T+ U" B3 b8 w* v" M$ G+ N, @+ P& \7 T( O0 N+ i7 r
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: 9 _4 w6 b) W3 L$ y9 |" r
197155 如何终止孤立进程 8 R( V! u6 m* s' B: }+ C
' \" m0 o5 c) U# O5 y
OleInitialize failed (or OleUninitialize failed). ( B- k, q1 C& \& b o8 K
, w' g1 y0 G4 ^; O8 ^9 nRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 8 w/ z/ j" w0 I- j) c
) q" a3 S3 p3 j, g! \+ a
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485
; ^4 V, Q9 M4 q9 g
$ O) g' _: _& G. ]" {4 {在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 5 \: H/ w7 l9 p. V H; D9 b
3 X4 q' g1 w9 v, w" q! y! U
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 6 h7 O% R0 L) y/ o- p9 @
8 H8 O3 m" V/ N2 ?. t0 `在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
( k9 S& ?- Y1 Y. o. b# R$ N
" _1 @/ H9 }: b7 A2 e- `LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
3 d8 F4 ~$ z& N9 o% p& L5 ]! V. j( y( ?" s/ z
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
. V W4 _) U# `; w2 i, {: S
9 y+ y0 m; G$ o8 v, b. ~2 |) n/ KDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串 0 s+ A$ c$ d( y
/ j2 L9 t7 t& o9 G& } d( ^在 Winerror.h 中搜索字符串。 9 O3 h1 V$ y" f' |- T* X
Regsvr32.exe 和依赖项 + F, S# X0 \: m8 A5 g
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 ' x& G% j( ?8 }& ^+ V# v
& E/ c- E& t- E# l" O$ s您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 & z1 U4 W% y* C
247024 Tools Included with the Microsoft Windows 98 Resource Kit |