using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace Util { public class Scheduler { [DllImport("CoreDLL.dll")] public static extern int CeRunAppAtTime(string application, SystemTime startTime); [DllImport("CoreDLL.dll")] public static extern int FileTimeToSystemTime(ref long lpFileTime, SystemTime lpSystemTime); [DllImport("CoreDLL.dll")] public static extern int FileTimeToLocalFileTime(ref long lpFileTime, ref long lpLocalFileTime); public static void AgendarDownload(string aplicativo, DateTime quando) { long fileStartTime = quando.ToFileTime(); long localFileStartTime = 0; Scheduler.FileTimeToLocalFileTime(ref fileStartTime, ref localFileStartTime); SystemTime systemStartTime = new SystemTime(); Scheduler.FileTimeToSystemTime(ref localFileStartTime, systemStartTime); Scheduler.CeRunAppAtTime(quando, systemStartTime); } } [StructLayout(LayoutKind.Sequential)] public class SystemTime { public ushort wYear; public ushort wMonth; public ushort wDayOfWeek; public ushort wDay; public ushort wHour; public ushort wMinute; public ushort wSecond; public ushort wMilliseconds; } }