How do I check if a COM component (EXE/DLL file) is registered or not using .NET?
If you have one machine where it is already registered, you can: Open regedit and search for your DLL filename. If it is registered, you will find filename under a key that is under the TypeLib. The key will look like: {9F3DBFEE-FD77-4774-868B-65F75E7DB7C2}
You can run a command-line tool called the Assembly Registration Tool (Regasm.exe) to register or unregister an assembly for use with COM. Regasm.exe adds information about the class to the system registry so COM clients can use the . NET Framework class transparently.
Summary. Regsvr32 is a command-line utility to register and unregister OLE controls, such as DLLs and ActiveX controls in the Windows Registry. Regsvr32.exe is installed in the %systemroot%\System32 folder in Windows XP and later versions of Windows.
Short answer is that you don't need to register DLLs in order to use them. The only exception to this is COM and ActiveX DLLs which need to add certain keys to the registry. For a normal DLL (including . NET class libraries), all you need to know is the path to the DLL.
Just make a lookup in the registry. HKEY_CLASSES_ROOT\yourcom.component.
It depends. Your component will be registered into the Windows Registry so you need to figure out which hive you want to look in.
If your component is installed with regasm, chances are HKCU will be used, since it will be run from a user's command line. If, however, you use an MSI, the MSI may not use regasm and may place the entries directly into HKLM if you run the MSI in PER MACHINE mode (ALLUSERS = "1") or as an admin. On the other hand, if you run the MSI as PER USER (ALLUSERS = "") or as an unprivileged account, it will use HKCU.
HKCR is merged view of HKLM and HKCU, so you can't tell which hive was actually used, and it might not give you what you want to know. MSDN HKEY_CLASSES_ROOT
If your COM component is registered PER USER, it might fail depending on which user ran the install. So if you want to check whether or not it was installed CORRECTLY, you need to figure out which key you actually want to use, or if HKCR is acceptable. For end user testing, HKCR might be the safest way to test as it will be accessible by everyone and (in .NET) will not throw security exceptions.
Also see this post: regasm and HKCU
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With