对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。
, O" a. R# x( J" P! P7 l& m* I4 N8 O0 a2 Q9 T# o
Regsvr32.exe 的用法 + {, z/ ~- t' I
! Y7 `$ W& n: H4 ]/ \% p4 _1 [RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname ; Z% W# ]) H8 H& k( v
5 \4 F+ \( s0 g( J8 M; _ /u - Unregister server<BR/> " N5 g, _& b+ N; c
/i - Call DllInstall passing it an optional [cmdline]; , P& m+ v( o3 H( O0 i& {1 l
when used with /u calls dll uninstall
; X6 J+ r+ m) n' {0 S2 o /n - do not call DllRegisterServer; this option must 1 [# ]% `1 z2 D2 f* n
be used with /i
) _8 s& u4 V2 O" {% L: K: ^( t4 p [2 w6 y
当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
& u8 X+ v+ n8 n: q1 X9 X' l+ bhttp://msdn.microsoft.com/librar ... n32_error_codes.asp
% y' C; e; \8 ?0 \. F: i O
1 C7 ~5 k/ Q$ G* P5 X# M8 \例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
1 l2 c- L- ]. h0 F. @6 t' y+ f4 ~c:\regsvr32.exe sample.ocx : q- o _" @4 g: @; m
5 W6 Q( N; t; ?Regsvr32.exe 错误消息 ) C2 ^4 n* F8 u: C) ^" O
0 \* S& Z8 k# T5 y
以下列表介绍了 RegSvr32 错误消息和可能的原因。
; K- q( r; ~. U1 X
/ ~3 Z5 ~% T. {! m0 n4 ?Unrecognized flag:/invalid_flag 7 O s: v( H0 w o$ J& p( V4 ]$ o
+ {7 @" y# a# W$ r键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 & ]7 g3 ?+ C! a2 @: |$ f
: O+ q& ~/ Q; V% `/ H) k/ O9 BNo DLL name specified. $ q+ q e& i5 \6 Z ?+ c# W4 [0 M
; c' V) U$ y4 m- Z7 n/ P! O+ ^1 @
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 0 j- G( i/ H _ f# ?8 J7 I2 C
; \3 _" @. g+ j( c
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
( Y7 A( v/ q7 Q: u% X
3 u6 Z7 K% _, {0 D) eDllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
, W- V9 l2 v- w [5 \" v6 b/ C& ]) J$ l9 q: _
Dllname is not an executable file and no registration helper is registered for this file type.
& d$ X8 J9 n) \: p- Q
7 Z6 Q5 L/ A- y3 oDllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。 % \2 K7 s3 A. ?/ R; |0 Z5 ?
+ u( e+ ?$ {) b1 ]" {- H
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
6 x9 ?' C, D& @
% U; j9 z6 b" lDllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。 ( k6 R6 z- V1 e
" d* U1 E+ H& K6 A( y
Dllname is not self-registerable or a corrupted version is in memory.
* K T2 q7 s% `! h
; ^8 z/ v/ ~4 r1 @8 D) O6 j' y例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: " R3 E( v' I. P# i( `
197155 如何终止孤立进程
7 f% U, r: X8 U; i! R% v; i* m- N; n: q+ S! `5 V
OleInitialize failed (or OleUninitialize failed).
K% L ]. { j& A0 j+ T5 y; k9 V
5 h3 H v0 M Q6 w2 jRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 ' W4 w7 {6 @) H+ A! p6 f/ b8 I: ~
3 v, z# R! ^8 L
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485
- M2 B; {7 c6 r* h+ V6 S- S9 o+ W) _, b9 {) N
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 0 B! F1 r! P7 I
" h% n. c$ z- k- m* e
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002
! K# V4 @% l# V3 }5 p x+ H( F6 B; b4 i" O: \6 a* e5 o
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。 . `. J5 h" Q( }' d' {/ J
# ~5 L9 J+ K0 h
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
3 s* X9 D) S7 f7 e$ v
& z' U0 `- L [" J在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
4 S/ [( Q) H& ? {+ F
) U7 _ [. E- `$ \$ rDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
! w+ p: D& d/ c# z& n7 x$ C: r8 \7 q
D3 I1 L ]+ F' N$ }, `3 F% o Q在 Winerror.h 中搜索字符串。 . O! Q; [4 w$ Y5 G O; s5 Z$ `+ T
Regsvr32.exe 和依赖项 6 h( w* I1 t- C4 h
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 - @& T# t" Y, m7 c9 D$ x
( t% y/ Q' U; b8 n您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 * U1 S+ B+ X, y* J/ a9 I+ `
247024 Tools Included with the Microsoft Windows 98 Resource Kit |