Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
cerunappattime (coredll)
 

coredll is for smart devices, not desktop Windows. Therefore, this information only applies to code using the .NET Compact Framework. To see if information for cerunappattime in other DLLs exists, click on Find References to the right.

.
Summary
This function prompts the system to start running a specified application at a specified time.

C# Signature:

[DllImport("coredll.dll", EntryPoint="CeRunAppAtTime", SetLastError=true)]  
private static extern bool CeRunAppAtTime(string pwszAppName, byte[] lpTime);

VB Signature:

    Public Declare Function CeRunAppAtTime Lib "coredll" _
       (ByVal AppName As String, ByRef ExecTime As SYSTEMTIME) As Boolean

User-Defined Types (VB):

    Public Structure SYSTEMTIME
    Dim wYear As Short
    Dim wMonth As Short
    Dim wDayOfWeek As Short
    Dim wDay As Short
    Dim wHour As Short
    Dim wMinute As Short
    Dim wSecond As Short
    Dim wMilliseconds As Short
    End Structure

Alternative Managed API:

CeSetUserNotificationEx

Notes:

In VB, function will return "true" if successful when adding app to run. However, it returns a "false" when cancelling the app even though the event is successfully cancelled. I'm guessing this is due to the systemtime structure being passed by reference and in this case references nothing. See sample code below. (VB .NET CF)

Tips & Tricks:

While this wakes the device, the screen may remain powered off. Combine with SetSystemPowerState truly wake up everything.

Also, if the app is making a call to wake itself back up, you can get the full path and appname with system.reflection.assembly. See code below for example.

VB Sample Code:

    Dim FullAppName As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase
    Dim AppPathOnly As String = System.IO.Path.GetDirectoryName(FullAppName)
    Dim NewDate As Date
    Dim wakeuptime As SYSTEMTIME

    Private Sub scheduleapp
    NewDate = Now
    'take the current time and date and add some hours, minutes, and seconds
    NewDate = DateAdd(DateInterval.Hour, 5, NewDate)
    NewDate = DateAdd(DateInterval.Minute, 10, NewDate)
    NewDate = DateAdd(DateInterval.Second, 30, NewDate)

    'populate systemtime structure with our new date
    With wakeuptime
        .wDay = NewDate.Day
        .wDayOfWeek = NewDate.DayOfWeek
        .wHour = NewDate.Hour
        .wMilliseconds = NewDate.Millisecond
        .wMinute = NewDate.Minute
        .wMonth = NewDate.Month
        .wSecond = NewDate.Second
        .wYear = NewDate.Year
    End With

    If CeRunAppAtTime(FullAppName, WakeUpTime) Then
        MessageBox.Show("App successfully scheduled to run")
    Else
        MessageBox.Show("Call to CeRunAppAtTime failed")
    End If
    End Sub

    Private Sub cancelschedule
    'Make a call to cancel the scheduled app
       Dim cancelapp as boolean = CeRunAppAtTime(FullAppName, Nothing)
    End Sub

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions