Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a COM component (EXE/DLL file) is registered or not (using .NET)? [duplicate]

Tags:

c#

.net

com

How do I check if a COM component (EXE/DLL file) is registered or not using .NET?

like image 838
softwarematter Avatar asked Sep 29 '09 11:09

softwarematter


People also ask

How do you find out if a DLL is registered or not?

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}

How do I register .NET COM DLL?

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.

Where are DLL registered in registry?

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.

Do DLL files need to be registered?

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.


2 Answers

Just make a lookup in the registry. HKEY_CLASSES_ROOT\yourcom.component.

like image 51
Arthur Avatar answered Sep 29 '22 10:09

Arthur


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

like image 38
DB Tech Avatar answered Sep 29 '22 09:09

DB Tech