对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。2 ~# y" A2 F7 R/ n0 {& a
! a! V9 |! j4 l# A: z8 `Regsvr32.exe 的用法 5 X9 T0 n5 e4 h' Q
3 m$ z2 `# x9 h( _+ T* jRegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname 3 k% ?7 E0 q* O+ s& B
5 P- `. r" F" ~& q /u - Unregister server<BR/> ) [ ~) X# c8 A6 ~1 ^
/i - Call DllInstall passing it an optional [cmdline]; " k# O5 u& v' y/ `7 X8 e; ~, a
when used with /u calls dll uninstall 6 T2 t! ]% i% P4 ~
/n - do not call DllRegisterServer; this option must
# O" c$ V- ^- ^ be used with /i
* I' A$ j; T2 M3 l3 i$ k
% ^1 d& |" Z5 A$ y5 b4 o6 ]当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: / x: `( s' l- Z) k1 G( T& L% v8 B
http://msdn.microsoft.com/librar ... n32_error_codes.asp
2 m5 b8 N: u7 X! z, b. d1 K0 m& y4 l' o8 ]
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: * u6 N2 ?) ?: n
c:\regsvr32.exe sample.ocx
) S$ B4 E+ O5 a: Z) p- m( ^3 v& d
, _$ s# _0 u1 C* ]5 jRegsvr32.exe 错误消息
' w/ {: I2 r& ]: i+ p; r/ O
P( T) P: Y# i7 N( `% X" v- f. x/ F以下列表介绍了 RegSvr32 错误消息和可能的原因。 ) c" q# h; v! n6 i) a( {
: x" u# {: |' e b" W7 XUnrecognized flag:/invalid_flag
' a0 e( Q9 E/ H7 P H; e' V3 j) ^
7 {# D" n# b6 p1 l4 U# K- A键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
4 C9 U) U& F" p3 R$ Y }* o& H0 i% ^. S0 |3 ?6 k
No DLL name specified.
( y& Z, m7 u# p) k6 u+ s! o7 j0 T& x, W3 e
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 3 e. D6 G, `2 l8 w4 G
& R& G# R1 p5 G9 _Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
; E1 |7 ? p: K+ [# P7 c5 c! u$ r& _! H: R. ^# M
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
4 p1 ]9 I5 V. c' `5 [ @, I
! Z- v8 A# {) B0 B* Y6 X: [Dllname is not an executable file and no registration helper is registered for this file type. h# V5 V+ H. o
, V1 Y+ Q/ ?" N- i9 y5 L+ l8 t$ n
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
# Y1 ]7 `; D H( ?. I4 y
) _6 E \: w; Y1 C r2 M( J$ E/ IDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
, U1 `7 u6 q) K
& X. f+ }; W/ m8 k& n$ B7 zDllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。 & ?% c$ U0 R0 y% }: D- s( z5 _
( k+ S1 S& @: Z. u) x2 [* ZDllname is not self-registerable or a corrupted version is in memory. 4 `$ i0 @. X) N/ m! D8 @$ j* V
0 p# j8 G% T9 W# C9 I0 j# k- {例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
. p0 Z/ x' y/ ]: } o197155 如何终止孤立进程 + c' H4 z& E2 I+ h
1 s# ]$ ^# k% _
OleInitialize failed (or OleUninitialize failed). 9 |( ]7 @% y* i1 x* u
5 M1 \+ L( W0 T' @& y$ ]$ URegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
! X8 U# ]4 R5 @& A7 ~' M4 U/ A$ l9 _, g* c9 h
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485
- l+ w3 t. X1 \5 `7 l6 A
# ]0 I, Z" Y6 k7 n: d% n在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 ( x' h2 h) n. b# `: {
) }: v) h6 y6 C, w! n/ y7 Q
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 " {( G$ J. X8 h. \$ k
b F! j8 O5 |2 A6 @; ~
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
& \# r P9 m, u$ \/ B
- z# l' E# S. C" Y' ]( fLoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f 3 P" L9 N. r2 x0 w* Q/ L
/ B% ~2 G; H3 V% A& W在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
; U4 N3 v4 \9 g$ R1 e3 K1 S9 e7 o2 h& K, V% C; h
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
2 H0 r2 J2 p% s) F% n0 }
* Y @$ M7 C% @! J" \3 O' L/ a, o' }在 Winerror.h 中搜索字符串。
/ y0 R5 [7 G. G9 B" i# ^& `% XRegsvr32.exe 和依赖项 # J$ V) k" u0 ^, i$ b7 q
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 ' v( R0 @3 P8 j4 g: g' a" Z
0 ~* u! B* Q5 x! B* k! G您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
* w8 S: r6 R6 f& l. Q247024 Tools Included with the Microsoft Windows 98 Resource Kit |