对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。
2 G9 W- f5 B' R' }6 G% x ^" T$ @# [1 E8 R: ] w
Regsvr32.exe 的用法
V' q4 s: K& Z( x- d4 T$ [* v2 N6 S) Z* K( K6 h+ R% b' b6 B. Y7 d
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname 0 }, g; ]# c7 E) ?: _+ N
+ Z- y4 j* E9 C, r /u - Unregister server<BR/>
9 z* ?( {$ y1 j4 C6 ` /i - Call DllInstall passing it an optional [cmdline];
! U) _& W/ G0 { when used with /u calls dll uninstall
/ ?; ^' k2 M5 x, }! n /n - do not call DllRegisterServer; this option must
) v }% m: l- P3 z# Z( z6 D be used with /i - \* W$ P1 s& B' b
$ \" c& c3 v& L
当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: 1 ]5 _: ^$ i, l# ^$ d2 d3 E
http://msdn.microsoft.com/librar ... n32_error_codes.asp 5 i( U) k. u+ w7 t" `" {
+ o; N {6 I% {0 b4 w
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
) C2 l* d! O" j% l$ n, V& K; O; rc:\regsvr32.exe sample.ocx " N$ k0 {$ I( R7 V
+ m* t" l8 U4 j6 ]8 O- _Regsvr32.exe 错误消息 0 I. {" w, |# g5 x8 ?
% W2 W6 A; M: ?0 t以下列表介绍了 RegSvr32 错误消息和可能的原因。 5 }8 w: {8 b9 y
, r, v5 Y- M/ N5 A# c
Unrecognized flag:/invalid_flag
6 u" R; C# [# o
; o8 n0 u& T3 r1 a键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
2 F% ]. u K1 B% a/ C( i# M4 i
9 Z5 X! y+ L! B5 i% |$ p. ]& vNo DLL name specified. # r! |1 P2 i9 z/ m6 H
% a& z7 L' P+ B1 R9 G6 l
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 : s: d# R# M/ a8 ^8 J* g5 R
# L+ }0 {+ q8 ~. Q) k' u M. w
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
9 u0 Y8 n+ m0 w* d( f9 w: Y) L: U9 ]$ C. X& Y
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
/ {% O4 x) Z/ _( f8 r8 X' M- Y' N6 p5 |1 ~, i
Dllname is not an executable file and no registration helper is registered for this file type.
" Z/ h& v+ s# [2 @/ Z/ ]0 M
, P; n' y6 h, p: ^" X# LDllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
4 N/ @& q6 f% f
! o: L9 j2 @, N0 \Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. 5 }# w- ^ Q. [5 h2 Z
" L$ r. X5 x8 v+ G- I; I
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
( X, O' ^- ]6 T0 R3 X) t+ g+ F4 h
Dllname is not self-registerable or a corrupted version is in memory.
# }! F0 G% ?: U* R! g2 q5 e
& r1 N4 c/ w0 m例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: . N) `4 j N0 E" u0 L
197155 如何终止孤立进程
; y0 r/ W4 o; [( y' m, |6 v6 o8 q
0 q G! S' G# C. O& l9 jOleInitialize failed (or OleUninitialize failed). 6 q. g0 N/ z8 x
# N ^6 M9 q8 ]. U4 _6 `
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 - a% f. m! r$ ]
' e) R, E; ~: w) r6 C7 LLoadLibrary("Dllname") failed.GetlastError returns 0x00000485 ; H7 Q8 i1 K1 h" o; W
( p) C/ ?: V% f; @* e' N4 M
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
2 }+ |: A, N. w6 [! ^7 @% E2 J6 E- T$ w3 m9 w) b
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002
" U$ e7 u9 F j7 f4 s$ ?
' {3 c" K p1 j3 k1 `: t3 m在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
9 ]8 G, H/ O$ e" t, V- r3 x' J$ `$ J4 y$ [
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
7 d- f% Y3 v n9 ]
. K# ]. j9 o; I% t" q- Y0 \ S在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 ( r3 U) p0 ^3 } L
! H0 P! Z G! P- Q- r
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
' \( r9 ?$ `4 P+ @( z! |7 N" v& A4 p/ ]2 t1 ^% q
在 Winerror.h 中搜索字符串。 % ]" ]$ w9 [6 `' _
Regsvr32.exe 和依赖项
- V8 j. p# t4 p1 K: J, j% a8 ? y; dRegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。
7 d+ ]! h4 I3 b0 V
1 g2 M" Z i7 t3 H7 E2 z' v您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
( f; \" b0 d0 K9 j! A247024 Tools Included with the Microsoft Windows 98 Resource Kit |