电脑互动吧

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

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

[复制链接]
发表于 2013-5-16 20:01:25 | 显示全部楼层 |阅读模式
对于那些可以自行注册的对象链接和嵌入 (OLE) 控件,例如动态链接库 (DLL) 文件或 ActiveX 控件 (OCX) 文件,您可以使用 Regsvr32 工具 (Regsvr32.exe) 来将它们注册和取消注册。% R  n0 a- Y0 n; s' S
. R2 C& u8 W  P0 B5 C% z) B  A8 b
Regsvr32.exe 的用法
1 [1 c# D* V, j: C1 s
' B8 d( z' B& o3 |+ [# E; B- K" {RegSvr32.exe 具有以下命令行选项: Regsvr32 [/n] [/i[:cmdline]] dllname # w; j1 T  F+ V( T" ]( r7 b3 v. V
" z- L3 a" Y! j' ?: B
   /u - Unregister server<BR/>
: g- t0 Y1 X. S$ ^/ \8 _   /i - Call DllInstall passing it an optional [cmdline]; 4 W# B. H. o; w) i( o
        when used with /u calls dll uninstall 5 r& s+ p) V( T4 B$ u, e: Z; U) F
   /n - do not call DllRegisterServer; this option must ' P+ p+ N+ }, w$ c
        be used with /i 3 V2 m& H0 j" Z9 O1 R" I
. I) N; ]/ l% Q% _2 [" N
当您使用 Regsvr32.exe 时,它会尝试加载该组件并调用它的 DLLSelfRegister 函数。如果此尝试成功,Regsvr32.exe 会显示一个指示成功的对话框。如果此尝试失败,Regsvr32.exe 会返回一条错误消息,其中可能会包括一个 Win32 错误代码。要查看 Win32 错误代码的列表,请参见下面的 Microsoft Web 站点:  
! i+ J# \; r: b7 U+ h3 F$ Jhttp://msdn.microsoft.com/librar ... n32_error_codes.asp  
6 {9 A; B3 j+ b) I2 ?0 T# x1 ~3 E" s! l8 `" S% W5 r
例如,要手动注册 Sample.ocx ActiveX 控件,请在 MS-DOS 提示符处键入以下命令:  
; R6 I. y) [* A& Ac:\regsvr32.exe sample.ocx
2 J3 Y& n% R# {3 ~( e
* s9 @! _! `/ z& iRegsvr32.exe 错误消息 $ r- N, B! t& ~' p( x

8 O! G& B0 |0 {, z3 Z0 ?8 x以下列表介绍了 RegSvr32 错误消息和可能的原因。  
0 O( i# C, ?7 ]8 F- P" w, Y
" b* p( H* i; g/ D' Q4 ~7 x6 EUnrecognized flag:/invalid_flag * a) B; z9 r( t" x! N0 l: C
/ M: W7 C! d$ v
键入的标志或开关组合无效(请参阅本文中的“Regsvr32.exe 的用法”一节)。  3 \  t8 @. `5 e* T
3 u7 B! g  i8 N' [9 O1 Z- u- m
No DLL name specified.
" [/ e+ U' t. B/ Q/ E
* E) h0 {" P  I. o5 r  q) V1 ^: z未包括 .dll 文件名(请参阅本文中的“Regsvr32.exe 的用法”一节)。  
& H4 X/ R0 L9 ^1 i& w7 a' _4 v; ]
2 a, m# m" p7 F, ~+ T% mDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found. 6 c5 s5 B' I8 A( h# y' j
: t+ n' Z! e0 P, C8 a
Dllname 不是 .dll 或 .ocx 文件。例如,键入 regsvr32 wjview.exe 就会生成该错误消息。  9 ?( Z+ l' m$ k- Y4 m% p
  m0 d+ }; t8 }0 k  S
Dllname is not an executable file and no registration helper is registered for this file type. 0 B/ F. S/ W% x7 n
3 r% ~, r* Z% H. `) d$ Z
Dllname 不是可执行文件(.exe、.dll 或 .ocx)。例如,键入 regsvr32 autoexec.bat 就会生成该错误消息。
, w3 A  J% S4 o  G
# p- Z. l9 t4 WDllname was loaded, but the DllRegisterServer or DllUnregisterServer entry point was not found.
& z3 A" I& x9 a% G6 j% K2 c' T2 a: ]* w  m
Dllname 可能未导出,或者内存中可能有损坏的 Dllname 版本。请考虑使用 Pview 来检测该文件并删除它。  
( @$ \9 y! B" a) f
! Z/ m# I- @- a* C! cDllname is not self-registerable or a corrupted version is in memory.
( t5 @; e4 a; {% L$ j6 k" z8 c) E- Z8 j& D" K0 \1 A' ?4 b, C# Z
例如,键入 regsvr32 icwdial.dll 后就会返回该错误消息,因为 Icwdial.dll 文件不能自行注册。如果您怀疑内存中有损坏的 Dllname 版本,请尝试重新启动计算机,或重新提取该文件的原始版本。如果您运行的是 Windows NT,可能需要使用 Microsoft Windows NT Server 4.0 资源工具包 中的 Kill 或 Pview 工具。有关其他信息,请单击以查看以下 Microsoft 知识库文章:  
# d, Y) }5 M6 L1 A$ u+ X197155 如何终止孤立进程  
. C! C% W1 l7 T% f( P9 s1 r5 q8 g/ ^2 D: V7 t$ h# x: F
OleInitialize failed (or OleUninitialize failed). : d: S/ ^- z* {

; h3 ]$ b5 {. |& @. HRegsvr32 必须先初始化 COM 库,然后才能调用所需的 COM 库函数并在关闭时撤消对该库的初始化。如果对 COM 库进行初始化或撤消初始化的尝试失败,就会出现这些错误消息。例如,Ole32.dll 文件可能已经损坏,或者其版本有误。  8 q9 `8 a" r7 G4 o& x, c: R- H) \

6 U3 X. s+ O3 F! }! TLoadLibrary("Dllname") failed.GetlastError returns 0x00000485 4 G  Q2 s( J. |+ I
  }  l# |. S* Q( V4 P& d% V
在 Winerror.h 中,0x00000485 = 1157 (ERROR_DLL_NOT_FOUND),表示“找不到运行该应用程序所需的某个库文件”。例如,键入 regsvr32 missing.dll 后,如果找不到 Missing.dll 文件,就会返回该错误消息。  
* d' y" F8 j' D" ^6 B5 \5 E
  u! O4 i8 L2 H* r' C9 tLoadLibrary("Dllname") failed.GetLastError returns 0x00000002 6 V4 i8 ?/ C+ x. {
! F7 N2 [+ A! y1 H& g: F$ A
在 Winerror.h 中,0x00000002 = 2 (ERROR_FILE_NOT_FOUND),表示“系统找不到指定的文件”。换言之,系统找不到相关的 DLL。例如,如果键入 regsvr32 icwdial.dll,而此时缺少 Tapi32.dll(依赖项),就会返回该错误消息。  
" ?5 W# y* O- L9 t0 ^) R% G" w. ^2 H! q
LoadLibrary("dskmaint.dll") failed.GetLastError returns 0x000001f 0 P) g  C& v; ]: [  D

$ [. z& F, B; e6 ?. ]7 `1 ]在 Winerror.h 中,0x000001f = 31 (ERROR_GEN_FAILURE),表示“附加到系统上的设备不能正常工作”。如果您尝试注册 Win16 .dll 文件,就会发生此现象。例如,键入 regsvr32 dskmaint.dll 会返回该错误消息。  2 x! E* g( A4 A$ s/ C; R7 I

( r) Q" o9 @3 o( f( t' K/ x. {2 CDllRegisterServer (or DllUnregisterServer)in Dllname failed.返回代码是:字符串 2 l: Y7 F" r5 F- O  h, P

3 `2 ]6 V4 `+ A# a  U在 Winerror.h 中搜索字符串。  
1 l6 g/ M$ j7 G  |4 P5 \9 fRegsvr32.exe 和依赖项 * n7 h  h# n9 n* ?
RegSvr32.exe 依赖于 Kernel32.dll、User32.dll 和 Ole32.dll 文件(在 Windows NT 中,还依赖于 Msvcrt.dll 和 Advapi32.dll 文件)。Regsvr32.exe 会加载您尝试注册或撤消注册的文件及其所有依赖项。如果缺少必需的文件或者它们已损坏,该进程可能会失败。  
* E. B5 l/ G) @9 q. B
! \5 V+ Z2 X' e5 L0 V$ K您可以使用 Depends.exe 来确定您尝试注册或撤消注册的文件的依赖项。在 Microsoft Windows 98 资源工具包 和 Microsoft Windows NT 4.0 资源工具包 支持工具中都提供了 Depends.exe。
$ T, {7 G" M% h. F! x, C247024 Tools Included with the Microsoft Windows 98 Resource Kit  
回复

使用道具 举报

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

本版积分规则

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

浙公网安备 33032402001025号

GMT+8, 2025-7-6 08:51 , Processed in 0.142655 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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