Should be a simple question, but searching the documentation is开发者_如何学Python driving me nuts. Suppose I have an ITypeInfo pointer for a coclass or an interface. How do I get the name of that class or interface?
Ok. It did turn out to be pretty simple. You just need to call the ITypeInfo.GetDocumentation
method with the member id set to MEMBERID_NIL
(−1). Like so:
CComBSTR typeName;
hr = typeInfo->GetDocumentation( MEMBERID_NIL, &typeName, NULL, NULL, NULL );
If you're programming in .NET, the above is conveniently performed for you by the Marshal.GetTypeInfoName
method:
// using System.Runtime.InteropServices;
string typeName = Marshal.GetTypeInfoName(typeInfo);
The short answer: you can't using ITypeInfo
. You can obtain the prog ID of class using the Win32 ProgIDFromCLSID
API. In COM the name of the underlying C++, Visual Basic or .NET class implementing the COM interface or co-class is practically meaningless. Only interface IDs, class IDs and programmatic IDs have any significance beyond the source code of your co-class's implementation: only these can be used for activating COM objects using CoCreateInstance
et al and runtime casting using QueryInterface
.
精彩评论