IOCTL_POWER values and CTL_CODE macro

  • Thread starter Thread starter Mario
  • Start date Start date
M

Mario

Hi,

I am using P/Invoke to call a method that takes IOCTL_POWER_XXX codes
as an input. The values that I need to get are defined by the macro
CTL_CODE as follow:

#define IOCTL_POWER_CAPABILITIES CTL_CODE(FILE_DEVICE_POWER, 0x400,
METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_POWER_GET CTL_CODE(FILE_DEVICE_POWER, 0x401,
METHOD_BUFFERED, FILE_ANY_ACCESS)

#define IOCTL_POWER_SET CTL_CODE(FILE_DEVICE_POWER, 0x402,
METHOD_BUFFERED, FILE_ANY_ACCESS)

My question is that how can I find the constants of these macros since
C# does not support macros. Thanks.

Cheers,

mario
 
You could write a simple program in C to let the preprocessor calculate them
for you, then hard-code the values. I think I did that for a couple of NDIS
macros, similar to what you're doing, when writing some of the OpenNETCF
networking code. That is, write a C/C++ program that just outputs the
values.

DEBUGMSG( 1, ( TEXT( "IOCTL_POWER_CAPABILITIES = 0x%x\r\n" ),
IOCTL_POWER_CAPABILITIES ) );

etc.

Paul T.
 
Back
Top