2012-01-08 14 views
0

这是IDL定义我的方法:出口结构中WINBASE.H定义与ATL的IDL

[id(3), helpstring("method GetBatteryStatus")] 
HRESULT GetBatteryStatus([out,retval] SYSTEM_POWER_STATUS_EX2* batteryStatus); 

SYSTEM_POWER_STATUS_EX2winbase.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;..... 

然后,如果我添加的typedef在IDL:

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. 

那么我怎样才能输出winbase.h中定义的SYSTEM_POWER_STATUS_EX2结构IDL?

回答

0

您可以在单独的IDL文件写IDL版本SYSTEM_POWER_STATUS_EX2和导入它只有MIDL

cpp_quote("#if 0") 
import "fake.idl"; 
cpp_quote("#else") 
cpp_quote("#include <orginial_header>") 
cpp_quote("#endif")