注册 DLL 有什么作用? [英] What does registering a DLL do?

查看:112
本文介绍了注册 DLL 有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何注册 dll,但我一直不确定我为什么要这样做或在什么条件下必须注册 dll.有人可以解释或指向我一些文档吗?

I know how to register dlls but I've never really been sure why I'm doing it or under what conditions a dll must be registered. Could somebody explain or point me to some documentation?

推荐答案

注册 DLL 时,将调用 DLL 中的 DllRegisterServer 方法入口点.类似地,DllUnregisterServer 在 DLL 未注册时被调用.

When a DLL is registered, the DllRegisterServer method entry point in your DLL is invoked. Similarly, DllUnregisterServer is invoked when a DLL is unregistered.

这篇 MSDN 文章所述:

指示进程内服务器为所有人创建其注册表项此服务器支持的类模块.如果此功能失败,则登记处的所有状态类是不确定的.

Instructs an in-process server to create its registry entries for all classes supported in this server module. If this function fails, the state of the registry for all its classes is indeterminate.

对于 COM DLL,您需要实现自己的 DllRegisterServerDllUnregisterServer 入口点方法,它们会根据需要进行注册/取消注册.DllRegisterServer 的示例代码可以在 这里.

For COM DLLs, you will need to implement your own DllRegisterServer and DllUnregisterServer entry point methods which do the registering/unregistering as appropriate. Example code for DllRegisterServer can be found here.

注册 DLL 的最终结果是 DLL 中组件的所有 CLSID 都注册在 HKEY_CLASSES_ROOTCLSID 下.这允许 CoCreateInstance 在从另一个 DLL 或应用程序实例化 COM 对象时找到正确的服务器.

The end result of registering a DLL is that all of the CLSIDs for the components in the DLL are registered under HKEY_CLASSES_ROOTCLSID. This allows CoCreateInstance to find the correct server when instantiating COM objects from another DLL or application.

DllUnregisterServer 将执行相反的操作,并从注册表中删除所有由 DllRegisterServer 放入的 CLSID.

DllUnregisterServer will do the reverse, and remove all of the CLSIDs from the registry that were put in there by DllRegisterServer.

可以在此处找到有关 DllRegisterServer 的更多一般信息.

More general information about DllRegisterServer can be found here.

这篇关于注册 DLL 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆