Getting the version of a COM object

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

[
  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


source to share


2 answers


Basically, I figured out that I need to get information using the ITypeLib interface. So here's 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();
      }
    }
  }

      

+1


source


The code> project has a class that will do this at runtime.



+1


source







All Articles