tags:

views:

54

answers:

2

I am accessing a .NET COM object from C++. I want to know the version information about this COM object. When I open the TLB in OLEVIEW.exe I can see the version information associated with the coclass. How can I access this information from C++? This is the information I get:

[
  uuid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX),
  version(1.0),
  custom(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, XXXX)
]
coclass XXXXXXXX{
    [default] interface XXXXXXXX;
    interface _Object;
    interface XXXXXXXX;
};
+1  A: 

The code project has a class that will do this at run time.

Kaiser Advisor
+1  A: 

Basically in the end I figured out that I need to get the information using the ITypeLib interface. So here is the solution:

  BSTR bstrTLBNameWithPath = ""; //set this to whatever you want

  if( bstrTLBNameWithPath )
  {
    ITypeLib * pTlib = 0;
    HRESULT hr = LoadTypeLib( bstrTLBNameWithPath,&pTlib );
    if( SUCCEEDED( hr ) && pTlib )
    {
      TLIBATTR * pTlibattr = 0;
      hr = pTlib->GetLibAttr( &pTlibattr );
      if( SUCCEEDED(hr) && pTlibattr )
      { 
        //do something with the info

        //release the information
        pTlib->ReleaseTLibAttr(pTlibattr);
        pTlib->Release();
      }
    }
  }
Shao