TCHAR *szAlarmApp = TEXT("\\windows\\Alarm.exe");
void SetAlarm()
{
BOOL ret;
SYSTEMTIME new_SysTime, old_SysTime;
FILETIME old_FileTime, new_FileTime;
GetLocalTime(&old_SysTime);
SystemTimeToFileTime(&old_SysTime, &old_FileTime);
ULONGLONG interval = (((ULONGLONG)old_FileTime.dwHighDateTime) << 32) + old_FileTime.dwLowDateTime
+ 15*1000*10000; // 15秒以后执行应用
new_FileTime.dwHighDateTime = (DWORD)(interval >> 32);
new_FileTime.dwLowDateTime = (DWORD)(interval & 0xFFFFFFFF);
FileTimeToSystemTime(&new_FileTime, &new_SysTime);
ret = CeRunAppAtTime(szAlarmApp,&new_SysTime);
if(ret)
{
MessageBox(g_hWnd,(LPCWSTR)L"---Set Alarm succeed!\n ---\\System\\Alarm.exe will run 15 seconds later.\n\n ---If \\System does not have "Alarm.exe", it will be wrong",(LPCWSTR)L"Set Alarm",MB_OK);
}
else
MessageBox(g_hWnd,(LPCWSTR)L"Set Alarm failed !!!!.",(LPCWSTR)L"Error",MB_OK);
}
复制代码
在应用层这么做就可以了,你可以在OEMSetAlarmTime中加些打印信息,看看是不是调用了它