怎么用C++语言设置Windows闹钟
1、先看看闹钟效果图(有声音),步骤2直接上源码(C++)

2、using namespace std;
#include "iomanip"
#include "iostream"
#include "windows.h"
#include "winbase.h"
#include "mmsystem.h"
int main()
{
cout<<setfill('0');
int int_time_data[4];
char char_time_data[5];
BOOL run_tiem=true;
for(;;Sleep(1000))
{
SYSTEMTIME time;
GetLocalTime( &time );
cout<<" 系统时间"<<setw(2)<<time.wHour<<":"<<setw(2)<<time.wMinute<<":"<<setw(2)<<time.wSecond;
if(run_tiem==true)
{
cout<<endl<<" 请输入定时提醒时间(XX:XX) ";
cin>>char_time_data;
int_time_data[1]=(char_time_data[0]-'0')*36000+(char_time_data[1]-'0')*3600+(char_time_data[3]-'0')*600+(char_time_data[4]-'0')*60;
run_tiem=false;
system("cls");
cout<<" 提醒时间" <<char_time_data[0]<<char_time_data[1]<<":"<<char_time_data[3]<<char_time_data[4]<<endl;
}
for(int sum_time_data=0;sum_time_data<=21;sum_time_data++)
cout<<"\b";
int_time_data[0]=time.wHour*60*60+time.wMinute*60+time.wSecond;
if(int_time_data[0]==int_time_data[1])
{
PlaySound(TEXT(".\\music.wav"), NULL, SND_FILENAME | SND_ASYNC );
MessageBox(NULL,"时间到","提示",MB_OK);
}
}
return 0;
}

3、setfill('0'); 空白地方填充“0”
int和char定义变量

4、BOOL定义为真,让for循环体的if只运行一次。

5、获取系统时间,显示系统时间,并将系统时间转换成秒。

6、显示系统时间,for循环不断刷新cout输出的显示。
