0

This is my method defined in IDL:

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

The SYSTEM_POWER_STATUS_EX2 is a struct defined in winbase.h, and this project is a ATLSmartPhone Project, the winbase.h is from Microsoft's SDK.

When I compile the project the error are :

error MIDL2025 : syntax error : expecting a type specification near "SYSTEM_POWER_STATUS_EX2"

If I add import "winbase.h" to the top of the IDL file, the error will be:

error MIDL2003 : redefinition : size_t; error MIDL2003 : redefinition : _LARGE_INTEGER;.....

Then if I add the typedef in in IDL:

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

The error will be:

error C2011: '_SYSTEM_POWER_STATUS_EX2' : 'struct' type redefinition.

So how can I export the SYSTEM_POWER_STATUS_EX2 struct which was defined in winbase.h with IDL?

iHunter
  • 6,205
  • 3
  • 38
  • 56

1 Answers1

0

You can write the IDL version of the SYSTEM_POWER_STATUS_EX2 in the separate IDL file and import it for MIDL only:

cpp_quote("#if 0")
import "fake.idl";
cpp_quote("#else")
cpp_quote("#include <orginial_header>")
cpp_quote("#endif")
Nikhil
  • 16,194
  • 20
  • 64
  • 81