CeRunAppAtTime 函數來排程

此範例是五秒鐘後播放一段音樂檔
[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); [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; }
public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { l
ong fileStartTime = DateTime.Now.AddSeconds(5).ToFileTime();
long localFileStartTime = 0;
FileTimeToLocalFileTime(ref fileStartTime, ref localFileStartTime);
SystemTime systemStartTime = new SystemTime();
FileTimeToSystemTime(ref localFileStartTime, systemStartTime);
CeRunAppAtTime(@"\Windows\Alarm1.wma", systemStartTime); }

留言

這個網誌中的熱門文章

使用VB讀取健保卡基本資料

使用VB讀取自然人評証卡號