对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。8 R! q: h6 k! P
5 Z3 y# ]/ \9 V" BRegsvr32.exe 的用法 - V4 Z) V3 W/ ?5 n
6 b x; d- `6 t( Y8 s
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname
2 h4 n6 T1 v/ X* V% v$ i7 z' }/ |+ A
/u - Unregister server<BR/> % i7 B2 F" ]/ c9 m6 u/ ], z1 O# s2 R
/i - Call DllInstall passing it an optional [cmdline]; & y6 }, L u4 |4 G" X
when used with /u calls dll uninstall
9 ~" f( f5 o5 r; t7 z( \+ S0 ] /n - do not call DllRegisterServer; this option must - j1 } d* f! V% a1 g2 y6 u5 |
be used with /i % v: L, O; E3 W7 p" L
+ a- ~! J1 B/ e) m( [当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:
6 N( k5 D' H) a5 uhttp://msdn.microsoft.com/librar ... n32_error_codes.asp % a" W; _, b: X: n; Q6 A
$ d5 K; l7 T- F% w3 I- ~- B例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
* ~7 T" K8 a" T+ R" _7 e. gc:\regsvr32.exe sample.ocx " ~9 Z4 b7 |9 t n u
- b* j, o5 L1 _( nRegsvr32.exe 错误消息
' d" T( q, F; G* B7 t3 w! ]+ N' z
以下列表介绍了 RegSvr32 错误消息和可能的原因。 7 s% M% i: Q- y$ q) p% H
$ N! [ o4 ~, I
Unrecognized flag:/invalid_flag
6 r6 L8 D5 J# v, ?6 n1 p+ h
/ F8 \* J* L" E' q5 k键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 7 \- @7 y2 q4 b3 r" W p8 m) l
, h" G2 { c- kNo DLL name specified.
" ~% z3 Y3 f! F* y4 _+ @6 p1 k: l. A+ ?
未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。
6 d' S$ p O. U9 u) @: A, c# o9 |3 x& `1 U3 Z/ w3 i
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
' [9 E" _% w- Y, a- _
' d) W+ R8 j+ y6 ]/ EDllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
! `( U" G; P7 k
+ y9 G$ I ]; `4 y! R+ T5 QDllname is not an executable file and no registration helper is registered for this file type.
; Y( \9 P/ @+ N
3 B' Y3 i2 N( l: d5 O, @Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
0 P. [# J* w$ b9 Q- q2 |* R, n+ k3 ^/ h$ H1 g. F1 a
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
. Z% \6 b- R7 r( v% H8 \7 }7 ]9 \/ _
8 t* q& D) _0 P, `1 k* o0 A! {/ O; pDllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
$ \' R: a N# a: x
, [( U$ @+ F$ \3 m9 I. WDllname is not self-registerable or a corrupted version is in memory.
* W- C: s/ w" O* V
+ v: C/ j) o" h' w1 f- y0 Q3 j/ W例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章: M+ P+ A5 H. W0 I" U/ m
197155 如何终止孤立进程 : t( Q) @' I y% W" M. m
( B/ \# v/ m, S% L1 KOleInitialize failed (or OleUninitialize failed). - r& z0 O" q9 \# x0 z
: H6 A, b, I5 `4 URegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 ( T1 x" X& b% [, a V( H" s- J
8 F: f" J' |* P7 R- w, PLoadLibrary("Dllname") failed.GetlastError returns 0x00000485 ) X8 G; n% `- ]' [
3 I% O+ {9 }' V+ t9 u* b
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
$ }$ J0 O3 n. b
3 n! G- @$ P; {3 K0 n% D. _LoadLibrary("Dllname") failed.GetLastError returns 0x00000002
7 K. `9 j8 w- \3 N8 _- ]8 h. |% T6 }% ?
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。 1 g$ P- u0 {$ h
. r% v& @- [) {; L* J# f ELoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
9 O$ O5 Z' N% R! B6 C) s/ I! K2 D S3 S# T _) y$ j$ m; ^
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
1 ~5 E6 `7 L- g3 q% N; K
# E' d! O; u7 i$ YDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
6 x, D4 w. o; t6 T" g @/ [
7 X* r( X- v8 Y+ e8 l在 Winerror.h 中搜索字符串。 / P0 i, @3 A) f) X. z
Regsvr32.exe 和依赖项
7 {, b5 k: I4 U, I$ pRegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。
: H9 I" z- I) n5 n
" f9 a; `( e+ o' F T1 O/ C您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 5 M t# j+ }; @9 e
247024 Tools Included with the Microsoft Windows 98 Resource Kit |