[HowTo] Application start on “Wake up” event

Using this code will allow you to configure your application to start or to display following a system wakeup event.

/// <summary>
/// This function starts running an application when a specified event occurs.
/// </summary>
///  <param name="application">The application. eg: @"\Program Files\testapp\testapp.exe"</param>
///  <param name="notificationEvent">Event at which the application is to be started. Use 'NotificationEvent' enum to get values.</param>
///  <returns>TRUE indicates success. FALSE indicates failure.</returns>
[DllImport("coredll.dll", SetLastError = true)]
public static extern int CeRunAppAtEvent(
            string application,
            NotificationEvent notificationEvent);

///  <summary>
/// Enum used in the "CeRunAppAtEvent" native method
/// </summary>
public enum NotificationEvent
{// Commented values are not common to all devices
    None = 0,
    TimeChange = 1,
    SyncEnd = 2,
    //START = 3,
    //SHUTDOWN = 4,
    //NETCONNECT = 5,
    //NETDISCONNECT=  6,
    DeviceChange = 7,
    RS232DEtected = 9,
    ResotreEnd = 10,
    Wakeup = 11,
    TimeZoneChange = 12,
    //MachineNameChange = 13
}

Usage :

 string kioskApplication = @"\Program Files\testapp\testapp.exe";
 Win32.CeRunAppAtEvent(kioskApplication, NotificationEvent.Wakeup);

External link :
CeRunAppAtEvent @MSDN


Leave a Reply