Getting CLSID for a DLL file?

妖精的绣舞 提交于 2019-12-04 18:05:17

问题


I want to create a small app to add and remove user defined context menu entries from the registry. To make this, somehow I need to get the CLSID of an arbitrary DLL so I can back up previous entries if they exist before writing new ones.

Although regsrv32 somehow manages to create this magical number, I didn't find any way to get that number myself.

I hope there is something better than this:

  1. scanning registry for the DLL name
  2. if not found, register it, scan again, and then unregister it again

If the DLL has been renamed, I can see a possibility for problems.


回答1:


You could consider calling LoadTypeLibEx on the DLL specifying REGKIND_NONE and then examine get the TypeLibInfo information available via the ITypeLib interface passed back to you.

There's some information about this sort of thing on MSDN. It's an old VB6-focused link but has useful information about inspecting COM components in this way.




回答2:


You could try to use RegOverridePredefKey() to intercept what regsvr32 does to the registry - call RegOverridePredefKey(), then reproduce what regsvr32 does - LoadLibrary() the COM server, call DllRegisterServer() - then inspect the changes done. With RegOverridePredefKey() you will isolate the changes and not let them become persistent.



来源:https://stackoverflow.com/questions/2280247/getting-clsid-for-a-dll-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!