对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。5 [& B* c# R! b9 w' R: I
# L' m' G4 j# h/ I8 A M% z
Regsvr32.exe 的用法 * P4 ~: B. E' g0 q, M5 R
! z, _ Y! P( M8 i6 u& |6 ]RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname
( m: a7 X- [4 ?* N; E) t& H
% D, G8 ]' k+ X5 ^. c4 i( K) | /u - Unregister server<BR/> % e. T* i+ U% O: G8 o
/i - Call DllInstall passing it an optional [cmdline]; 1 }! Y0 F+ q8 C- Z; T
when used with /u calls dll uninstall 2 Y4 J5 _. M' T* m" Y1 T5 W
/n - do not call DllRegisterServer; this option must 6 f' N" O3 l2 S. W
be used with /i
8 s9 R, a9 P; K7 ?9 N5 V
2 j, R% M2 n1 x' k) s* U3 Q; u2 |6 f当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
& E I9 a5 b- Chttp://msdn.microsoft.com/librar ... n32_error_codes.asp
& j$ n2 a+ s& L: w4 t1 O3 v k* r1 |" s
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
' J+ b8 A7 U, Q" Mc:\regsvr32.exe sample.ocx
; R8 t2 ^3 d$ i3 L' j) S6 }1 @) ^3 F# P" `, H- d# \5 W
Regsvr32.exe 错误消息
: K- Q4 K$ |& E2 T8 f
5 g* _& J( m8 d9 }- H" w2 y2 Q以下列表介绍了 RegSvr32 错误消息和可能的原因。
7 r1 O: _! ?8 {# l' y9 N7 O T- ~, Z; K* z3 u4 {; b v- F+ X
Unrecognized flag:/invalid_flag
4 n$ X3 B9 y" M0 x* S/ l- Z$ G/ _+ Y4 C2 Q8 i5 L7 d
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
1 a H9 x- ^' H* p) o4 G9 Y9 p" m
+ M$ {/ _, l3 R$ a& [No DLL name specified.
# _% ~: J: o3 ]& ]" ?2 _' @2 p8 S+ a2 s/ c0 I s6 g8 e
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 - D; ^7 h! e$ H7 M
5 B* y8 Z& S3 Z e% c( LDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. 5 e0 b I. s/ Z, a
' s% ~2 Q! F! U0 {$ j/ d+ T
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 2 K0 ~/ x: f! ?' P) x/ F# q6 f8 |- C
! a& D1 D4 s( a: ^& i( gDllname is not an executable file and no registration helper is registered for this file type.
4 c9 k, P+ n2 N S: B# |
9 c7 M: n4 ]. } ODllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
0 P- u9 x; }$ I9 G% {
6 M& M. S5 {2 W% `9 R6 `: gDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
7 t2 f# N2 ~- I |# d; D! \7 D3 N4 ^' n; C4 U
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
5 { I0 M4 I& w2 N
, O; l; s: N! A- V6 H) KDllname is not self-registerable or a corrupted version is in memory. 5 z. w/ N0 w- }- K5 T, k
+ h, b" i# E0 L, T0 A y例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
' |3 a: ]5 \8 m6 C197155 如何终止孤立进程
) ^1 L; k! ]2 g7 g8 Y$ E
& [' V' }, C( D' [ d7 [OleInitialize failed (or OleUninitialize failed).
; E" u8 b+ ^" d- S! \! y' ]
& d2 G o- k; ] wRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 2 c2 B* ]0 h, D* }6 Z8 }1 L( Z
1 ~- \! m5 h' T! MLoadLibrary("Dllname") failed.GetlastError returns 0x00000485 9 h! a! t" _8 b* R* k3 d+ q
7 y1 e1 A2 B7 c% b, k
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
2 W e5 Y- I g9 i1 }4 |1 u( H6 b+ S
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 1 s; M7 P4 C" b3 O' r) q3 V
, L( y* f4 K; k. b在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。 & w Z1 L7 t* C( Y- g& W1 V6 j' N
( T( @2 K# H8 yLoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f - I3 N' q* n* t, K% w2 H
, p& Y, S- w b$ i( a
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 - ~8 K I+ M) e' n, q3 _* B
9 T- I. U+ L: g! lDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串 - N ^& }; U7 H! U9 ^ |4 o
' e/ y4 @. ~ p. E. V
在 Winerror.h 中搜索字符串。 6 ^: B8 L; J# T$ L, {3 s
Regsvr32.exe 和依赖项 4 ?5 y: G' e' j7 x3 _
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 9 Z: S: `2 C8 y8 h* c B9 T- j" d! n
" W- J7 |; O0 E" k, l/ G" Z8 t您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
. l6 S7 C3 ?6 ?7 N9 I247024 Tools Included with the Microsoft Windows 98 Resource Kit |