regsvr32 是否有 .NET 或 Win32 版本?
regsvr32 是否有 .NET 或 Win32 版本?我想用代码注册一个 COM DLL,而不是使用 regsvr32 程序。
Is there a .NET or Win32 version of regsvr32? I would like to register a COM DLL with code instead of shelling out to the regsvr32 program.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
注册程序集的标准方法是调用程序集导出的 DllRegisterServer 函数。
简而言之,regsvr32 本质上执行以下操作(为简洁起见,省略了错误检查)。
The standard way of registering an assembly is to call the exported
DllRegisterServer
function on the assembly.In simplified terms regsvr32 essentially does the following (error checking omitted for brevity).
是的,它只需要调用导出的函数。但问题在于细节。该 DLL 还将加载所有隐式链接的依赖 DLL。他们的 DllMain() 入口点将运行。这在像 regsvr32 这样的简单过程中还可以,但在您需要在注册步骤之后继续存在的过程中就不那么好了。
然后获得写入注册表的权限。 UAC 肯定会阻止这种情况,无论是运行 Regsvr32 还是直接调用入口点。要获得用户的许可,您需要一个单独的 EXE,其中包含要求管理员权限的清单。你没有领先。
查看免注册 COM,在清单中提供注册信息。这样您就不必再注册 DLL。如果你搜索这个词,你会得到很多点击。
Yes, it simply requires calling the exported function. The devil is in the details though. The DLL will load all its implicitly linked dependent DLLs as well. And their DllMain() entrypoints will run. That's kinda okay in a simple process like regsvr32, not so okay in yours that needs to survive beyond the registration step.
Then there's getting the permissions to write to the registry. UAC will definitely put a stop to that, both for running Regsvr32 as well as calling the entrypoint directly. To get permission from the user you will need a separate EXE with a manifest that asks for admin rights. You're not ahead.
Look into reg-free COM, supplying the registration info in a manifest. You then won't have to register the DLL anymore. You'll get lots of hits if you search for the term.
我相信您只需加载 DLL,然后调用它导出的
DllRegisterServer()
函数即可。I believe you just load the DLL, then call it exported
DllRegisterServer()
function.