[ACCEPTED]-How to check if a COM component (EXE/DLL file) is registered or not (using .NET)?-com
Just make a lookup in the registry. HKEY_CLASSES_ROOT\yourcom.component.
It depends. Your component will be registered 25 into the Windows Registry so you need to 24 figure out which hive you want to look in.
If 23 your component is installed with regasm, chances 22 are HKCU will be used, since it will be 21 run from a user's command line. If, however, you 20 use an MSI, the MSI may not use regasm and 19 may place the entries directly into HKLM 18 if you run the MSI in PER MACHINE mode (ALLUSERS 17 = "1") or as an admin. On the 16 other hand, if you run the MSI as PER USER 15 (ALLUSERS = "") or as an unprivileged 14 account, it will use HKCU.
HKCR is merged 13 view of HKLM and HKCU, so you can't tell 12 which hive was actually used, and it might 11 not give you what you want to know. MSDN HKEY_CLASSES_ROOT
If 10 your COM component is registered PER USER, it 9 might fail depending on which user ran the 8 install. So if you want to check whether 7 or not it was installed CORRECTLY, you need 6 to figure out which key you actually want 5 to use, or if HKCR is acceptable. For end 4 user testing, HKCR might be the safest way 3 to test as it will be accessible by everyone 2 and (in .NET) will not throw security exceptions.
Also 1 see this post: regasm and HKCU
From Visual Studio you can do this from 6 the Reference Manager.
- Go to Solution Explorer > References
- Right click on References
- Choose Add Reference...
- Choose the COM item from the menu
The nice thing about 5 this tool is you can search for the objects 4 by keyword a bit more elegantly than navigating 3 through the registry. Note you can see 2 the non-COM objects registered in the GAC 1 as well.
More Related questions