Search code examples
c#registry

How to check COM dll is registered or not with C#?


I need to check if msdia100.dll is registered on a computer system that I'm running in order to register the dll with the command regsvr32.exe. How can I do that with C#?


Solution

  • You can search through the registry for this. Assuming that you don't know the COM objects contained in the DLL you'll have to start looking for the DLL name first in HKEY_CLASSES_ROOT.

    Then use the class name to find the CLSID in HKEY_CLASSES_ROOT\[ClassName]\CLSID and finally you should be able find it the CLSID as HKEY_CLASSES_ROOT\CLSID\[CLSID].

    Please note, registry locations written from memory so might be a bit off.

    Edit: Or if you know the class name you could just try to create an instance of it and see if it works or not.