views:

18

answers:

1

Say I've got a load of COM types and I'd like to check if a particular type has been registered. I can use Activator.CreateInstance to actually try and create the class, but I was wondering if there's a simpler way actually check in advance if the class is actually registered.

I'd prefer not to go to the registry directly - I'm looking for something easy to use like the Activator.CreateInstance call above.

Thanks

+1  A: 
Richard
Good point - my understanding of how the COM interop works is pretty basic. Thanks for the answer though - it's how I would have naively done it. Out of interest, would the registry way not be a pain if you have to deal with 32\64 bit issues?
cristobalito
@cristobalito there are potentially a lot of places to check, by restricting to inproc cases you can reduce it to `HKCR:\CLID\<clsid>\InProcServer32` and `HKCU:\Software\Classes\CLSID\<clsid>\InProcServer32` (registry path remapping will handle the 32/64bit issue for you).
Richard
If you go for the registry solution you need to take care of "reg free COM" also.
Vagaus