电脑互动吧

 找回密码
 注册
查看: 6730|回复: 0

[技术资讯] Regsvr32 用法和错误消息的说明

[复制链接]
发表于 2013-5-16 20:01:25 | 显示全部楼层 |阅读模式
对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。
1 m$ L3 U/ D/ t$ T+ _* A
0 \! {4 b$ x3 M- D7 b8 aRegsvr32.exe 的用法
  c5 e% G; t, _+ G& O: y% \/ e$ s" O. G
RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname 6 H7 `9 z  N9 i* |. }
; a3 w- P, A$ Q3 h8 w: Z
   /u - Unregister server<BR/>
" C+ W- n6 S3 C: Y* f   /i - Call DllInstall passing it an optional [cmdline]; $ E( D0 \5 L  u4 @# a
        when used with /u calls dll uninstall
; `9 S. S# G; C/ O7 p( b& ?   /n - do not call DllRegisterServer; this option must 5 L7 y) H; M* S, j) ~
        be used with /i 8 n( r4 w. S/ Y' g' s  T

. O6 u9 k5 N7 h当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:  
% c  H1 W4 Y6 i& ~" J2 Hhttp://msdn.microsoft.com/librar ... n32_error_codes.asp  ; j$ H0 m( f3 A" [5 D

# [8 I4 h( l+ b+ u例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:  ! y. @0 H! [- N# s! C8 ]) t5 p4 b. L
c:\regsvr32.exe sample.ocx
* {& Z+ C  N+ s0 E7 [1 w+ E" F# S6 f: k+ ]; Q2 l6 O
Regsvr32.exe 错误消息
- z+ Z( R& `3 B3 a1 Y2 [7 j
& z( Q' `- e' P$ I以下列表介绍了 RegSvr32 错误消息和可能的原因。  
* I  ~, S' T+ q: q  ~3 l/ j/ Q6 l2 t+ A5 y# X& u4 a
Unrecognized flag:/invalid_flag
8 z" K3 @: v) f% Z! n- O- D% m9 _! p5 {9 X* x: J# p) [  @' ^
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。  # R! r/ D0 G8 I2 F- {

/ [- K8 J5 G' X" `No DLL name specified.
: n; }9 f0 c2 s4 h
' x# [# ?( m, {) V5 h' p- F未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。  
) g; }" n, G6 s6 P- ~' I
$ K6 L) T& w9 t) |8 O& S  h1 ?Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. 5 G$ o+ P' M4 e4 v5 `9 r& o8 N

; c! T' L8 P. l  a* DDllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。  9 d+ a3 ]8 E4 a. E
% O: n+ h- Z1 x# u# C7 q; d$ F
Dllname is not an executable file and no registration helper is registered for this file type.
2 o# j( L2 N8 t7 g' @6 P" ~! }( l  u' b. o9 ~
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。   X  {; I5 j$ B# X6 E1 W" o& m( M. i
& i$ E" W+ t3 c5 a7 x+ P; S, _( Z" F
Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. 5 @) h/ B, _) g; S/ y- E) k
. T' `$ o9 m0 Z2 o$ ^
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。  ( E# ?3 {7 V' a! V  d
, p9 ]5 B4 J; T2 p
Dllname is not self-registerable or a corrupted version is in memory. 6 n4 j% h* X5 j+ @( e& B$ d
2 g+ V$ y) E) t9 T, R1 b% U8 J
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:  
6 C: z) t6 N" v197155 如何终止孤立进程  1 Z: ~2 V2 i$ b! C! M

3 ~+ L; F0 H' N5 n+ d0 F/ ]% |' t8 Q; COleInitialize failed (or OleUninitialize failed). - c4 R* @% C  ~" _7 p  Q

. F& e% @8 F' I! jRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。  ) ^2 \& @8 r; m' Q$ T7 ?& g. @
0 h* V: f# n6 K1 }* T
LoadLibrary("Dllname") failed.GetlastError returns 0x00000485
# D) I9 X. J8 C% y. ?( D5 y
9 n; v" ?! I1 F2 ]在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。  . s( I* p' q) t2 i) o: G
3 d/ h4 @- H+ b" P
LoadLibrary("Dllname") failed.GetLastError returns 0x00000002 - B. N  o, \0 u' F: n2 O; i: ?+ H
. X. t" N  q5 Y+ c( j
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。  % i5 z% G% M# ^% H4 S; p% k

; m1 X' E4 q2 T; `* P6 cLoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f
- K" H/ J4 m0 z3 T; D9 W4 q/ F; Z! L( k
在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。  
) o9 E" d. B" R! d
* [6 m5 f6 W+ Q. M5 _3 f' IDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串
" w2 [3 Z6 U% S# Y  e8 q  ?% O6 Y; C4 G- h% j
在 Winerror.h 中搜索字符串。  
' d3 {) F; R# y. z. ^Regsvr32.exe 和依赖项
% O' ^. y; H* ~9 Y' yRegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。  2 A$ ?* [1 s% @: l0 ]% V+ ^
, z5 d. W6 T* m
您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
0 e/ H0 [" y+ j* Z247024 Tools Included with the Microsoft Windows 98 Resource Kit  
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系我们|手机版|小黑屋|Archiver|电脑互动吧 ( 浙ICP备13037409号 )

浙公网安备 33032402001025号

GMT+8, 2025-5-3 16:56 , Processed in 0.049705 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表