这是我在 IDL 中定义的方法:
[id(3), helpstring("method GetBatteryStatus")]
HRESULT GetBatteryStatus([out,retval] SYSTEM_POWER_STATUS_EX2* batteryStatus);
这SYSTEM_POWER_STATUS_EX2
是一个定义在 中的结构winbase.h
,这个项目是一个 ATLSmartPhone 项目,winbase.h
来自微软的 SDK。
当我编译项目时,错误是:
error MIDL2025 : syntax error : expecting a type specification near "SYSTEM_POWER_STATUS_EX2"
如果我添加import "winbase.h"
到 IDL 文件的顶部,错误将是:
error MIDL2003 : redefinition : size_t; error MIDL2003 : redefinition : _LARGE_INTEGER;.....
然后,如果我在 IDL 中添加 typedef:
typedef[public,uuid(37DE998A-6787-415a-A191-861C315D1248),helpstring("Power Status")]
struct _SYSTEM_POWER_STATUS_EX2 {
...
...
} SYSTEM_POWER_STATUS_EX2;
错误将是:
error C2011: '_SYSTEM_POWER_STATUS_EX2' : 'struct' type redefinition.
那么如何导出使用 IDLSYSTEM_POWER_STATUS_EX2
定义的结构呢?winbase.h