| 对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。 4 S/ M, @0 L2 a4 y3 S0 C. H( X7 h
 0 ]2 @3 K) W! [! F/ z4 H- tRegsvr32.exe 的用法
 1 \* j, a0 ]" P5 Z/ [9 d' C* B
 # E/ D! U4 f8 @& g: }! d. HRegSvr32.exe 具有以下命令行选项: Regsvr32  [/n] [/i[:cmdline]] dllname 8 L, m" u# J1 p" C0 e# K
 % `! i& d9 u, n; O4 {
 /u - Unregister server<BR/>
 7 _/ N& z$ S( _+ M! `4 o3 s" g   /i - Call DllInstall passing it an optional [cmdline]; " d0 x! ]) E3 _4 K6 }& |5 V8 l. y
 when used with /u calls dll uninstall ' m5 G$ h8 g8 a: n0 a, d
 /n - do not call DllRegisterServer; this option must   V/ k  T! r1 ~  r) T, V. e. X
 be used with /i
 / J) }  _- E6 R! P3 d" j5 B9 J) V8 P8 {$ @& f5 J" v
 当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:  6 G0 c- y; }" |
 http://msdn.microsoft.com/librar ... n32_error_codes.asp
 3 `( X( v; ]2 f& a3 S% q4 Z' P# G; F
 例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:
 # l$ y3 {6 Q. A! A- K/ u+ oc:\regsvr32.exe sample.ocx ! a; J$ M+ R7 T; w% d) I
 # M  H. Y$ h6 }
 Regsvr32.exe 错误消息   K  S) N0 L! p: i
 1 u8 D1 {. r1 P1 L( C2 Q) U
 以下列表介绍了 RegSvr32 错误消息和可能的原因。  0 |) x  j: M1 Z6 _' L
 & ]0 T" b  Q5 x6 _" O+ H
 Unrecognized flag:/invalid_flag - `- @& A7 y4 [
 2 @6 O2 t6 f, X& i, R
 键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。
 & A- s! e: E# N! F
 6 p* I6 t9 g  W' I% r1 m; }No DLL name specified.
 . e/ @4 X7 J4 x, |% @6 a: ?/ @; V6 Y0 o5 k
 未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。  # j$ z0 U( p$ I# s( a9 O! ]9 Q
 
 " V) g$ j, ^6 XDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. ' [5 k4 N% ~* w% o* f. X- h( Q6 Y% B
 
 ! A, o! X  ^; h0 UDllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。
 + N. I3 k9 P6 l' s. a; q
 # s# @# s) V8 [/ d+ [, z: XDllname is not an executable file and no registration helper is registered for this file type.
 $ R4 l/ |3 d8 C/ k( E3 Q2 i( y! Z& Z4 g) t) D8 N( c0 M
 Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
 6 `1 E; o5 Y! k* k0 \3 Q0 n2 k$ G! j5 R. g$ q+ s8 x
 Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. # w7 ?; T0 C8 Z4 d6 U' Z& E
 4 P: W- a' h! U( U% Q6 ?9 |9 W
 Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。
 & u+ i5 o& T" o9 Z% B5 G; D" q/ m4 O9 A8 f
 Dllname is not self-registerable or a corrupted version is in memory. 3 ~7 `8 ~/ V( y! O1 a
 
 8 x3 f/ e+ O+ s" I7 S例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:
 2 S5 g; E: F) e9 f; V$ |# t197155 如何终止孤立进程
 * C. e7 e/ o; g, f  O/ `
 8 E# c4 ?/ u! Y' ^+ n! H* }OleInitialize failed (or OleUninitialize failed). / _$ Z' K# g4 V+ ^
 / [0 E! i) {5 _. e
 Regsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。  ; b" M/ c. ?1 ?  q
 9 m: _) F; _+ b
 LoadLibrary("Dllname") failed.GetlastError returns 0x00000485 * I% J! ^; _6 h1 m1 e" Q
 
 - ?- S/ _# }2 n/ y, {# n在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。
 , d; D4 x/ `" @! _- Q. r& A! A$ ^; t
 LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 1 A# X* G: g* d2 R' f8 s9 r# P
 ' E( y8 t% h; L& ?) k
 在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。  : |1 o" D0 Q- E7 t
 ' {! b! x& `# h. s- Y
 LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f ; D4 Z$ S; V- c
 
 3 v* ?' T6 G  b) l/ K在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。
 - Z: \/ s' o! R3 H0 u$ s8 `8 ~0 ?# e6 A  Y
 DllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
 . j- C! \% p; k0 t4 o. ]
 4 z' p0 t  x, n& a7 d; ]" ]9 v5 Z/ [在 Winerror.h 中搜索字符串。  : q! B: ]% ]$ ~8 _
 Regsvr32.exe 和依赖项 5 V8 s6 D4 e- S
 RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。  & M/ ^: L  W' m; D# H5 f
 " Z5 I. q7 n% x5 C" ~. z
 您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
 7 z) y' e6 l- H247024 Tools Included with the Microsoft Windows 98 Resource Kit
 |