按時提醒win32提醒,無窗口

 //每50分鐘提醒一次,放卡農,彈出框,沒有窗口,後臺運行,採用多字節字符集windows

 
#include <conio.h>
#include <cstdlib>
#include <windows.h>
#include <process.h>//多線程支持
#pragma comment(lib, "WINMM.LIB")//playsound須要該庫
 
#define ONEHOUR 3600000//一小時
#define FIFTYMINUTES 3000000 //50分鐘
#define TENMINUTES 600000//10分鐘
#define TESTTIME 300000//5分鐘
 
 
unsigned int __stdcall PlayMusic(void *  p);
unsigned long hThreadHandle;
unsigned uThreadID;
 
 
INT WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    PSTR lpCmdLine, INT nCmdShow)
{
MessageBox(NULL,"Begin!","Reminder",MB_OK);
for(int i = 0; i < 24; ++i){
Sleep(FIFTYMINUTES);
hThreadHandle = _beginthreadex(NULL,0,PlayMusic,0,0,&uThreadID);
MessageBox(NULL,"Have a rest!","Reminder",MB_OK);
}
    return 0;
}
 
unsigned int __stdcall PlayMusic(void *  p){
//char music[10];
//strcpy_s(music, "kanon.wav");
PlaySound(TEXT("kanon.wav"), NULL, SND_FILENAME|SND_SYNC);
return 0;
}
相關文章
相關標籤/搜索