views:

687

answers:

4

Hi

I have created a class library using c#.And i have registered the class library using

regasm..

  RegAsm.exe Discovery.dll /tlb: Discovery.dll /codebase

Now i want to know whether the assembly is registered or not using c++. I need because I have to check the registry for this dll if it is not registered I have to registered it programatically if it is registered then i simply skip it.

so How can i know whether the assembly registered or not using c++...

A: 

Usually the library UUID can be found in the registry under HKEY_CLASSES_ROOT\CLSID{guid}. By checking for that key, you know if the dll was registered. The RegGetKeyValue may do the trick.

xtofl
+1  A: 

Check the registry unter HKEY_Classes_Root:

  • HKEY_Classes_Root\CLSID contains all class IDs
  • HKEY_Classes_Root\Interface contains all interface IDs
  • HKEY_Classes_Root\TypeLib contains all type library IDs

Use the RegOpenKeyEx function to open the key. If the key exists, the function returns success.

devio
How to programatically find it using c++ any Idea???
Cute
You have already been given that information. Use RegOpenKeyEx() to open the "HKEY_CLASSES_ROOT\TypeLib\{typelib guid foes here}" key.
Remy Lebeau - TeamB
+1  A: 

Why do you need to bother at all? There is no harm to registering it again if it IS already there.

Goz
+3  A: 

Use LoadRegTypeLib to load it, and check the return value for errors. For example:

HRESULT hr;
ITypeLib *libraryIntf;

hr = LoadRegTypeLib(IID_GuidOfTypeLibrary, LibraryVersionMajor,
    LibraryVersionMinor, 0, &libraryIntf);
if(SUCCEEDED(hr))
{
    libraryIntf->Release();
    libraryIntf = NULL;
    // Type library is registered and can be loaded.
}
else
{
    // Type library is not registered.
}
Jon Benedicto