Expand Minimize

DeviceNotifyCallbackRoutine function

An application's DeviceNotifyCallbackRoutine callback function is used for receiving power notifications.

Syntax


DEVICE_NOTIFY_CALLBACK_ROUTINE DeviceNotifyCallbackRoutine;

ULONG CALLBACK DeviceNotifyCallbackRoutine(
  _In_opt_ PVOID Context,
  ULONG Type,
  PVOID Setting
)
{ ... }

Parameters

Context

The context provided when registering for the power notification.

Type

The type of power event that caused this notification.

Setting

The value of this parameter depends on the type of notification subscribed to.

Return value

This function returns a Windows error code.

Examples

To define a DeviceNotifyCallbackRoutine callback function, you must first provide a function declaration that identifies the type of callback function you're defining. For example, to define a DeviceNotifyCallbackRoutine callback function that is named MyDeviceNotifyCallbackRoutine, use the DEVICE_NOTIFY_CALLBACK_ROUTINE type as shown in this code example:


DEVICE_NOTIFY_CALLBACK_ROUTINE  MyDeviceNotifyCallbackRoutine;

Then, implement your callback function as follows:


_Use_decl_annotations_
ULONG
CALLBACK 
 MyDeviceNotifyCallbackRoutine(
  PVOID Context,
  ULONG Type,
  PVOID Setting
  )
 {...}

The DEVICE_NOTIFY_CALLBACK_ROUTINE function type is defined in the Powrprof.h header file. To more accurately identify errors when you run the code analysis tools, be sure to add the _Use_decl_annotations_ annotation to your function definition. The _Use_decl_annotations_ annotation ensures that the annotations that are applied to the DEVICE_NOTIFY_CALLBACK_ROUTINE function type in the header file are used. For information about _Use_decl_annotations_, see Annotating Function Behavior.

Requirements

Minimum supported client

Windows 8 [desktop apps only]

Minimum supported server

Windows Server 2012 [desktop apps only]

Header

Powrprof.h

See also

PowerRegisterSuspendResumeNotification
DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS

 

 

Community Additions

ADD
Show:
© 2015 Microsoft