Windows ce 使用ATL'导出winbase.h中定义的结构;s IDL

Windows ce 使用ATL'导出winbase.h中定义的结构;s IDL,windows-ce,atl,idl,windows-mobile-6.5,Windows Ce,Atl,Idl,Windows Mobile 6.5,这是我在IDL中定义的方法: [id(3), helpstring("method GetBatteryStatus")] HRESULT GetBatteryStatus([out,retval] SYSTEM_POWER_STATUS_EX2* batteryStatus); SYSTEM\u POWER\u STATUS\u EX2是在winbase.h中定义的结构,该项目是一个ATLSmartPhone项目,winbase.h来自Microsoft的SDK 当我编译项目时,错误是:

这是我在IDL中定义的方法:

[id(3), helpstring("method GetBatteryStatus")] 
HRESULT GetBatteryStatus([out,retval] SYSTEM_POWER_STATUS_EX2* batteryStatus);
SYSTEM\u POWER\u STATUS\u EX2
是在
winbase.h
中定义的结构,该项目是一个ATLSmartPhone项目,
winbase.h
来自Microsoft的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;.....
error C2011: '_SYSTEM_POWER_STATUS_EX2' : 'struct' type redefinition.
然后,如果我在IDL中添加typedef:

typedef[public,uuid(37DE998A-6787-415a-A191-861C315D1248),helpstring("Power Status")]
struct _SYSTEM_POWER_STATUS_EX2 {
  ...
  ...
} SYSTEM_POWER_STATUS_EX2;
错误将是:

error MIDL2003 : redefinition : size_t; error MIDL2003 : redefinition : _LARGE_INTEGER;.....
error C2011: '_SYSTEM_POWER_STATUS_EX2' : 'struct' type redefinition.

因此,如何使用IDL导出在winbase.h中定义的
SYSTEM\u POWER\u STATUS\u EX2
结构?

您可以将
IDL
版本的
SYSTEM\u POWER\u STATUS\u EX2
写入单独的
IDL
文件中,并仅为
MIDL
导入:

cpp_quote("#if 0")
import "fake.idl";
cpp_quote("#else")
cpp_quote("#include <orginial_header>")
cpp_quote("#endif")
cpp_引号(“#如果0”)
导入“fake.idl”;
cpp_引号(“其他”)
cpp_报价(“包括”)
cpp_引号(“#endif”)