获取COM对象的版本
我正在从C++访问.NET COM对象。我想知道有关此COM对象的版本信息。当我在OLEVIEW.exe中打开TLB时,我可以看到与coclass关联的版本信息。如何从C++访问这些信息?这是我得到的信息:获取COM对象的版本,com,Com,我正在从C++访问.NET COM对象。我想知道有关此COM对象的版本信息。当我在OLEVIEW.exe中打开TLB时,我可以看到与coclass关联的版本信息。如何从C++访问这些信息?这是我得到的信息: [ uuid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX), version(1.0), custom(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, XXXX) ] coclass XXXXXXXX{ [defa
[
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;
};
有一个类将在运行时执行此操作 基本上,最后我发现我需要使用ITypeLib接口获取信息。因此,解决方案如下:
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();
}
}
}