我正在从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{
[default] interface XXXXXXXX;
interface _Object;
interface XXXXXXXX;
};发布于 2008-11-15 21:02:08
基本上,最后我发现我需要使用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();
}
}
}发布于 2008-11-13 20:00:17
code project有一个将在运行时执行此操作的类。
https://stackoverflow.com/questions/288045
复制相似问题