我有一个ComTypes.STGMEDIUM对象,我想要获取它的IStorage。在STGMEDIUM struct成员的帮助下,您可以从pstg获得它。ComTypes.STGMEDIUM类缺少这样的成员。
发布于 2012-10-30 18:21:16
它就在那里,联合被展平为一个简单的IntPtr类型的字段。您可以直接对其进行强制转换:
#include <windows.h>
using namespace System::Runtime::InteropServices;
//...
ComTypes::STGMEDIUM foo;
IStorage* pStore = (IStorage*)foo.unionmember.ToPointer();或者,如果您愿意,也可以编组整个结构:
::STGMEDIUM native;
Marshal::StructureToPtr(foo, IntPtr(&native), false);
IStorage* pStore = native.pstg;https://stackoverflow.com/questions/13135518
复制相似问题