对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。
0 _, Q: ?' Q' L( |! F% V- ]1 p7 {% s0 v+ r2 y3 h
Regsvr32.exe 的用法
! Z+ i4 u3 J, P$ v& q% D, K( Y
) B& Y& p0 I+ W! z. u& yRegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname 7 A6 a( j6 u0 d- {8 h; T
4 O* J- {2 V' Y
/u - Unregister server<BR/> : F. o) J* a9 J
/i - Call DllInstall passing it an optional [cmdline]; 1 x% N+ _* t/ H6 [1 O* l! u
when used with /u calls dll uninstall
9 J' @, \) c0 i/ D, c /n - do not call DllRegisterServer; this option must
' B7 a( _. W5 L0 P6 X$ A) ^& A be used with /i ( |0 P0 \# I" y4 e3 \
% ^& ? g3 O ?+ [" S* w当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: . M# f2 C, [7 y- J0 a" _# |
http://msdn.microsoft.com/librar ... n32_error_codes.asp
/ L7 {' ^( I& T
5 f; Q/ o3 h/ Q$ z Z& _例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: 4 X' F$ g! z* `
c:\regsvr32.exe sample.ocx 8 H; X( W- O6 [3 c
6 E& k5 u9 ~) s, b
Regsvr32.exe 错误消息 3 o' h+ m- `# s. M
3 S5 l" m- z& P3 }+ s4 \# m以下列表介绍了 RegSvr32 错误消息和可能的原因。 , C: v5 X1 Y _) u! I+ P. Q4 d
+ p! }) K& Y, ]% p' Q5 w
Unrecognized flag:/invalid_flag
! n+ P+ p+ c8 E; W5 _' X* q9 h: h5 Q# d/ N
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 % _! b8 ^0 F5 I5 i
1 q0 `3 W) b% N, jNo DLL name specified. % {' ]& ^& C8 U+ j3 a w
* E! v. \% K" h7 f- c0 Q) o未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 & C1 Z3 `+ P+ s, r9 R( F
6 f6 ~. f( J2 j1 l; MDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. 2 V+ i7 l1 E2 l t6 C
0 U6 h4 m2 X& K$ r
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
3 r! i/ v W0 m3 C8 P+ k, ?# a) p( j, @% x, B7 e) L% @" T0 b
Dllname is not an executable file and no registration helper is registered for this file type. " e! f+ K$ [ N% \
7 S9 T) w6 L5 R: C( n: @# S2 ZDllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
8 e9 Z( Z2 e, d3 Q& j0 q' Q i- W) G1 \4 e: U6 q
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. , V$ |2 _; V; m
& y# T# _7 M( C$ R# h2 _$ a
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
% c$ I0 N3 I# j v7 u- F( `
1 {! l9 P& G, L, g% e. b$ U- g, e yDllname is not self-registerable or a corrupted version is in memory. 9 v& }+ n' \( ^, |$ x, K
) u9 x" q+ ^! ~1 z& L& O
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: ( r4 y4 H4 ?2 S. x
197155 如何终止孤立进程 6 Q# j) c6 w' z* T6 t& q: {) c4 d
9 j" h0 U6 f5 N, X6 l% m& ~/ ~OleInitialize failed (or OleUninitialize failed). 1 ~: I4 x. k8 [$ P, ^
: n! s6 J h" p3 \# ^) JRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。
' Z8 D5 H& d2 D( }: Q" {! B% `: v* w% z! \7 f& A1 @; V
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485
. A* o1 L& g1 v+ f6 U: ]2 M
' _* b! t( s1 _/ h9 }7 P( \$ z& m7 x在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 ! h( e: G$ e' f: T/ G7 c* }
. [6 q! d) W; T1 [4 \( WLoadLibrary("Dllname") failed.GetLastError returns 0x00000002 5 t. c. D N' S. K
" K; O. w4 f1 Y6 C3 d1 Q1 j6 @ Y
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
# g R( t; |0 m& j8 S# H* }# ?) t/ ?# ^# _, ^; `' x! v0 B/ p. f8 h
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
( {6 z" F+ M C
: f2 L& J- s" x/ B7 {- O. W在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
) l7 s, f! c- _9 v5 p. | H' {1 u' f* v# M
DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
% V0 n! r( t% x; k+ G+ U4 p! h3 U( e% t) \( E4 V
在 Winerror.h 中搜索字符串。
3 f* v5 U+ `# k# P! s3 \$ F! M1 xRegsvr32.exe 和依赖项
, f3 b3 Z6 K+ f- q: Q, V) sRegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 * |+ F- g* O+ L* r1 K+ c/ _
, _6 K6 _" ]( b- N您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
& ^% M; T8 H1 d& k4 l. E247024 Tools Included with the Microsoft Windows 98 Resource Kit |