public void runAppAtTime(string sApp, SYSTEMTIME stStart, SYSTEMTIME stEnd)
        {
            CE_NOTIFICATION_TRIGGER cnt = new CE_NOTIFICATION_TRIGGER();
            cnt.Type = CeNotificationType.CNT_TIME;
            cnt.StartTime = stStart;
            cnt.EndTime = stEnd;
            cnt.pApplication = @"\windows\fexplore.exe";
            cnt.pArgs = "";
            cnt.Size = (UInt32)Marshal.SizeOf(cnt); // Needs to compile with /unsafe

            uint hNotificationEx = SetUserNotificationEx(0, cnt, null);
            if (hNotificationEx > 0)
                MessageBox.Show("Successfully created a notification. Handle: " + hNotificationEx.ToString());
            else
                MessageBox.Show("Failed to create a notification");
        }
 public CE_NOTIFICATION_TRIGGER(byte[] Buf, uint Size, ref int Index)
 {
     int iEndOfString;
     System.Text.UnicodeEncoding enc = new UnicodeEncoding();
     uint lpszApp = 0;
     uint lpszArgs = 0;
     this.Size = BitConverter.ToUInt32(Buf, Index);
     Index += 4;
     this.Type = (CeNotificationType)BitConverter.ToUInt32(Buf, Index);
     Index += 4;
     this.Event = (CeNotificationEvent)BitConverter.ToUInt32(Buf, Index);
     Index += 4;
     lpszApp = BitConverter.ToUInt32(Buf, Index);
     Index += 4;
     lpszArgs = BitConverter.ToUInt32(Buf, Index);
     Index += 4;
     this.StartTime = new SYSTEMTIME(Buf, Index);
     Index += 16;
     this.EndTime = new SYSTEMTIME(Buf, Index);
     Index += 16;
     if (lpszApp > 0)
     {
         iEndOfString = WinCE.WinCE.findEndOfString(Buf, Index, (int)Size);
         this.pApplication = enc.GetString(Buf, Index, iEndOfString - Index - 2);
         Index = iEndOfString;
     }
     if (lpszArgs > 0)
     {
         iEndOfString = WinCE.WinCE.findEndOfString(Buf, Index, (int)Size);
         this.pArgs = enc.GetString(Buf, Index, iEndOfString - Index - 2); // Stupid solution to double null ending..
         Index = iEndOfString;
     }
 }
 public static extern void GetLocalTime(SYSTEMTIME sysTime);
        /*
        The following code will create a time based trigger and connect that trigger to a notification that will fire up \windows\fexplore.exe.
        Note that you need to compile this sample with the /unsafe switch. You could always hard code the size of CE_NOTIFICATION_TRIGGER in which case /unsafe won't be necessary. If hard coded; the value is 52.
        Also don't forget to pass NULL instead of ceun if you change the trigger type to CNT_EVENT.
        */
        public void newRunAtTime(SYSTEMTIME stStart, SYSTEMTIME stEnd){
            CE_NOTIFICATION_TRIGGER cnt = new CE_NOTIFICATION_TRIGGER();
            CE_USER_NOTIFICATION ceun = new CE_USER_NOTIFICATION();
            cnt.Type =CeNotificationType.CNT_TIME;
            cnt.StartTime = stStart;
            cnt.EndTime = stEnd;
            cnt.pApplication = @"\windows\fexplore.exe";
            cnt.pArgs = "";
            cnt.Size = (UInt32)Marshal.SizeOf(cnt); // Needs to compile with /unsafe

            ceun.ActionFlags = PUN_FLAGS.PUN_LED;
            ceun.sDialogText = "Dialogtext";
            ceun.sDialogTitle = "Title";
            ceun.nMaxSound = 0;

            uint hNotificationEx = SetUserNotificationEx(0, cnt, ceun);
            if (hNotificationEx > 0)
                MessageBox.Show("Successfully created a notification. Handle: " + hNotificationEx.ToString());
            else
                MessageBox.Show("Failed to create a notification");
        }
 public static DateTime GetAsDateTime(SYSTEMTIME st)
 {
     return new DateTime(st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
 }