对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。
) m& ]3 [; L4 [9 q0 }6 J$ O6 K& M5 a0 [; E E K" G6 f0 M
Regsvr32.exe 的用法
" P8 n+ j! a' C" |
+ T- {6 g3 b" K. R- `0 o; xRegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname 4 T- ?1 b+ C* e
' @* c, s1 w0 Y, D/ `7 ? /u - Unregister server<BR/>
! f6 C, B3 e. X /i - Call DllInstall passing it an optional [cmdline]; + G( `9 x5 R# o h' a
when used with /u calls dll uninstall , {1 w# N6 n$ u. h! a
/n - do not call DllRegisterServer; this option must 9 R" I. N9 t; t
be used with /i
' [; |5 g& I, F5 K1 U; g$ d* p
8 S8 B7 V+ x6 f5 }' Q当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点: 5 j& j: U' @5 S, q m( r) h
http://msdn.microsoft.com/librar ... n32_error_codes.asp 2 i6 g) m. `& K- a
2 `5 }$ @+ c! _/ K9 b F$ Y
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令: 6 l2 V) p8 n; [9 Z! t. Q: R% l6 ^1 l
c:\regsvr32.exe sample.ocx ! j# p% a" k5 U+ O
]3 p& ]& s( a1 b, hRegsvr32.exe 错误消息
; a9 C/ g" N! X* m2 t0 ~. k
( |1 C G7 ^" s7 n以下列表介绍了 RegSvr32 错误消息和可能的原因。 + H; R' {3 n- I4 q* ^
! ` l' I# o2 |' Y) qUnrecognized flag:/invalid_flag
! h1 A8 r c. K- X
: ?' @5 |, K$ \- @. I键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。 % E6 a6 x' [$ X7 h6 E6 |0 ?
- N+ O% Y/ x2 Q( q% l# b! KNo DLL name specified.
a. f( H) R( \3 G/ q9 ~, U
9 s5 r/ q, q" V6 ^未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。 ' k% q& ^7 f6 J& ]/ F
% O! @* H. E* h1 l$ M( e9 ODllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
. @- E! i( [% O8 G7 B* i2 g. z
# T. v" r+ P% R4 ^, wDllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。 / ~% S: u2 [1 r, p* l
3 d; E) a" r; A4 q% W2 s$ a. P$ xDllname is not an executable file and no registration helper is registered for this file type. % N3 p) S F* t
. W8 x9 n' ?9 m
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
! X! L x& M" _6 E$ V6 D' S' j, a: b( j
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
. I/ S9 | s8 `' {6 X# H
6 l% Z/ f1 i" x( ]' y- YDllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。 % {3 U- R# r1 h* F
- C: f% k: C! X) ^ l) r. D) Y
Dllname is not self-registerable or a corrupted version is in memory. 9 J0 S' ~2 h5 C) v; C8 }. t
) ^ o9 R8 j; `
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
) D4 j t1 R/ ^0 e7 i, @197155 如何终止孤立进程
) H$ U4 w6 R5 P1 N8 J, o
% W4 h% R3 s1 W" c2 D8 ZOleInitialize failed (or OleUninitialize failed).
7 {& g: l0 T1 g8 n" m* ]5 i" |1 O: M1 S$ T0 a
Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。 8 Y( K* c) Z/ e V8 D$ u
: v$ S# O0 D( u* ULoadLibrary("Dllname") failed.GetlastError returns 0x00000485
5 r2 s$ G5 m" ]0 e& V! z$ |+ W3 N3 c
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。 # s% h1 Y" ]1 C% u; L5 E* Z
# k* Z' E9 c( f: g6 g6 Y( fLoadLibrary("Dllname") failed.GetLastError returns 0x00000002 . |) l7 E5 n% {, w0 G9 z' V
/ p4 p' \0 _, y! @/ Y2 ^& c& {在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。
2 u q- G+ q3 R, |5 o A
5 J6 ?* {% k8 JLoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f / P$ ^! S: v7 y+ ~. w9 l2 w
, p, U+ K" f7 s7 V: a* y/ u在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。 9 ?) U" f1 j( r( y
% b# p; H+ B5 s5 a3 K3 Q% cDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
$ g0 J/ f: t& f+ q3 f
& c* ]5 K+ K4 n* F4 n在 Winerror.h 中搜索字符串。 4 s& T6 s3 Q( S5 A: f" o
Regsvr32.exe 和依赖项
" x9 x% U: P& Q7 n8 |+ l; v a3 X, ZRegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。 t7 r5 @' K! B/ d6 L
$ V6 j) P" _0 k您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。 5 d+ ~. L0 s7 }# g1 E- c5 y6 C0 q
247024 Tools Included with the Microsoft Windows 98 Resource Kit |