3

I want to retrieve the CSLID of my own dll from within my dll. This CLSID is declared in the .rgs file of my application.

I am creating a lot of the dlls, each with a different CLSID, and it would be important to me that I can easily retrieve it dynamically.

Can anybody please tell me how to do that?

Thank you.

tmighti
  • 31
  • 1
  • 3
  • 1
    [CLSIDFromProgID()](http://msdn.microsoft.com/en-us/library/windows/desktop/ms688386(v=vs.85).aspx), assuming your DLL is registered, will do what you want. Just make sure you know the prog ID if you coclass (its also in the rgs file, as well as the registry after proper registration). – WhozCraig Apr 21 '13 at 08:03

2 Answers2

3

A DLL doesn't have a CLSID, classes do. A simple way to get the guid for a particular class is to just use the name for it, auto-created when you added the class using the wizard. Say you added a class named "Example", you can use CLSID_Example in your code. Yet another way is to use the __uuidof keyword, write __uuidof(Example) in your code, that also works in client code when you imported the type library with the #import directive.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
1
  1. Use GetModuleFileName to get the path of the dll - Get DLL path at runtime
  2. Then get the CLSID from the typelib - Given a COM DLL, extract all classes CLSID and corresponding interface name
Community
  • 1
  • 1
user93353
  • 13,733
  • 8
  • 60
  • 122