简体   繁体   English

COM dll注册时收到错误80004005

[英]Recieving error 80004005 on COM dll registration

I have a Delphi COM dll which works perfectly on several machines. 我有一个Delphi COM dll,可以在几台机器上完美运行。 However when I try to register it on one Windows 7 box I get the following error 但是当我尝试在一个Windows 7机器上注册它时,我收到以下错误

DllRegisterServer failed with error code 0x80004005

I have tried the obvious solutions around ensuring that the correct supporting libraries are registered. 我已经尝试了明确的解决方案,以确保注册正确的支持库。

The solution which I found here was to elevate the call to regsvr32 我在这里找到的解决方案是提升对regsvr32的调用

Running CMD as administrator and then calling regsvr32 from the command line solved my immediate issue, but didn't track down the main bug. 以管理员身份运行CMD然后从命令行调用regsvr32解决了我的问题,但没有找到主要错误。

That error code is E_FAIL which is the generic COM error code. 该错误代码是E_FAIL ,它是通用的COM错误代码。 It means, something went wrong, but we aren't going to be any more specific than that . 这意味着, 出了点问题,但我们不会比这更具体

So, what did go wrong? 那么,出了什么问题? Well, you have the COM server, and we don't. 好吧,你有COM服务器,我们没有。 So you can debug it to find out. 所以你可以调试它来找出答案。 Build the COM server with debug enabled, and debug DCUs for the RTL files too since you'll want to debug them perhaps. 在启用调试的情况下构建COM服务器,并为RTL文件调试DCU,因为您可能想要调试它们。

You'll want to debug the code that responds to registration. 您需要调试响应注册的代码。 That's the TComServer.UpdateRegistry method. 这是TComServer.UpdateRegistry方法。 That code in turn calls registration methods on the various class factories that you declared. 该代码依次调用您声明的各个类工厂的注册方法。 The failure could be in your registration code, or the default registration code. 失败可能在您的注册码或默认注册码中。 You need to debug the execution of the registration code. 您需要调试注册代码的执行。 Do that by using regsvr32 as your host process. 通过使用regsvr32作为主机进程来做到这一点。 Set a break point at the start of UpdateRegistry , and then debug to work out what the problem is. UpdateRegistry的开头设置一个断点,然后进行调试以找出问题所在。

I can see that by trial and error you have discovered that your COM server needs to be registered with admin rights, presumably because it writes to HKLM. 我可以看到,通过反复试验,您发现您的COM服务器需要使用管理员权限注册,大概是因为它写入了HKLM。 There's no way that, given your question, that information could have been discerned. 鉴于您的问题,没有办法可以辨别出信息。 And so I wrote this generic answer to show how to debug and diagnose such a general problem. 所以我写了这个通用的答案,以展示如何调试和诊断这样的一般问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM