再烂也是自己做的,再好也是别人写的,在此留念。
vs2022+win11
电脑助手.cpp
#include"Mu_Lu.h"
#include"Xuan_Ze.h"
#include"xing_cheng_qian_zhi.h"
#include
#include
using namespace std;
DWORD WINAPI Fun(LPVOID IpParamter)
{
vectorVxc;
while (1)
{
Vxc = an_pai_jia_zai();
tong_zhi_pan_duan(Vxc);
Sleep(60000);
}
}
int main(int argc, char* argv[])
{
HANDLE hThread = CreateThread(NULL, 0, Fun, NULL, 0, NULL);
CloseHandle(hThread);
mu_lu ml;xuan_ze xz;
while (1)//一级目录
{
system("cls");
ml.zong();
int xuan_ze_1;
cin >> xuan_ze_1;
if (xuan_ze_1 == 0)
return 0;
switch (xuan_ze_1)
{
case(1)://二级目录
{
while (1)
{
system("cls");
ml.ding_shi_guan_ji();
int xuan_ze_2;
cin >> xuan_ze_2;
if (xuan_ze_2 == 0)
break;
xz.dong_tai_bi_zhi(xuan_ze_2);
}
break;
}
case(2)://二级目录
{
while (1)
{
system("cls");
ml.dong_tai_bi_zhi();
int xuan_ze_2;
cin >> xuan_ze_2;
if (xuan_ze_2 == 0)
break;
xz.dong_tai_bi_zhi(xuan_ze_2);
}
break;
}
case(3)://二级目录
{
while (1)
{
system("cls");
ml.ji_shi_ben();
int xuan_ze_2;
cin >> xuan_ze_2;
if (xuan_ze_2 == 0)
break;
xz.ji_shi_ben(xuan_ze_2);
}
break;
}
default:
{cout << "无关选项,请重新选择:" << endl; system("pause"); break; }
}
}
}
Mu_Lu.h
#pragma once
#include
using namespace std;
class mu_lu
{
public:
void zong()
{
cout << "-------------------------" << endl;
cout << " 1.定时关机 " << endl;
cout << " " << endl;
cout << " 2.动态壁纸 " << endl;
cout << " " << endl;
cout << " 3.行程 " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " 输入0统一视为退出 " << endl;
cout << "-------------------------" << endl;
}
void ding_shi_guan_ji()
{
cout << "-------------------------" << endl;
cout << " 1.关机 " << endl;
cout << " " << endl;
cout << " 2.定时关机 " << endl;
cout << " " << endl;
cout << " 3.重启 " << endl;
cout << " " << endl;
cout << " 4.定时重启 " << endl;
cout << " " << endl;
cout << " 5.取消定时关机/重启 " << endl;
cout << "-------------------------" << endl;
}
void dong_tai_bi_zhi()
{
cout << "-------------------------" << endl;
cout << " 1.壁纸显示 " << endl;
cout << " " << endl;
cout << " 2.壁纸导入 " << endl;
cout << " " << endl;
cout << " 3.查看路径库 " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << "-------------------------" << endl;
}
void ji_shi_ben()
{
cout << "-------------------------" << endl;
cout << " 1.行程安排 " << endl;
cout << " " << endl;
cout << " 2.查看行程 " << endl;
cout << " " << endl;
cout << " 3.删除行程 " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << " " << endl;
cout << "-------------------------" << endl;
cout << "行程安排需要助手处于运行状态。" << endl;
}
void ji_shi_ben_1()
{
cout << "-------------------------" << endl;
cout << " 1.早晨8点。 " << endl;
cout << " " << endl;
cout << " 2.中午13点。 " << endl;
cout << " " << endl;
cout << " 3.前一日晚21点。 " << endl;
cout << " " << endl;
cout << " 4.自定义时间。 " << endl;
cout << "-------------------------" << endl;
}
};
Xuan_Ze.h
#pragma once
#pragma warning( disable : 4996 )
#include"xing_cheng_qian_zhi.h"
#include"Mu_Lu.h"
#include
#include
#include
#include
using namespace std;
class xuan_ze
{
mu_lu ml;
public:
void ding_shi_guan_ji(int xuan_ze)
{
switch (xuan_ze)
{
case(1):
{
system("shutdown -s"); break;
}
case(2):
{
char a[25] = "shutdown -s -t ";
char b[10] = "";
cout << "关机将于几分钟后执行?"<> c;
c *= 60;
while (d < c)
{
d *= 10;
}
d /= 10;
for (int i = 0; d != 1; d /= 10, i++)
{
int e = c / d;
b[i] = e + 48;
c = c % d;
if (d != 1)
{
b[i + 1] = 0 + 48;
}
}
for (int i = 0, j = 0; b[j] != '\0'; i++)
{
if (a[i] == '\0')
{
a[i] = b[j];
j++;
}
}
system(a);
break;
}
case(3):
{
system("shutdown -r"); break;
}
case(4):
{
char a[25] = "shutdown -r -t ";
char b[10] = "";
cout << "重启将于几分钟后执行?"<> c;
c *= 60;
while (d < c)
{
d *= 10;
}
d /= 10;
for (int i = 0; d != 1; d /= 10, i++)
{
int e = c / d;
b[i] = e + 48;
c = c % d;
if (d != 1)
{
b[i + 1] = 0 + 48;
}
}
for (int i = 0, j = 0; b[j] != '\0'; i++)
{
if (a[i] == '\0')
{
a[i] = b[j];
j++;
}
}
system(a);
break;
}
case(5):
{
system("shutdown -a"); cout << "关机/重启取消。" << endl; break;
}
default:
{
cout << "无关选项,请重新选择:" << endl; system("pause"); break;
}
}
}
void dong_tai_bi_zhi(int xuan_ze)
{
switch (xuan_ze)
{
case(1):
{
cout << "点也没用,啥也没有。" << endl; system("pause"); break;
}
case(2):
{
cout << "别试了,这个也啥也没有。" << endl; system("pause"); break;
}
default:
{
cout << "无关选项,请重新选择:" << endl; system("pause"); break;
}
}
}
void ji_shi_ben(int xuan_ze)
{
switch (xuan_ze)
{
case(1):
{
system("cls");
time_t now = time(NULL);
tm shi_jian = *localtime(&now);
cout << "请选择月份:" << endl;
int dang_qian_yue_fen;
cin >> dang_qian_yue_fen;
dang_qian_yue_fen -= 1;
if(dang_qian_yue_fen> shi_jian.tm_mday;
cout << "开始时间为几时:" << endl;
cin >> shi_jian.tm_hour;
cout << shi_jian.tm_hour << "时几分:" << endl;
cin >> shi_jian.tm_min;
time_t yu_yue = mktime(&shi_jian);
cout << "活动/行程为:" << endl;
wstring xing_cheng;
wcin.imbue(locale("", LC_CTYPE));
wcin >> xing_cheng;
time_t tong_zhi; dang_qian_yue_fen = 1;
while (dang_qian_yue_fen)//三级目录
{
system("cls");
cout << "请选择通知时间:" << endl;
ml.ji_shi_ben_1();
int xuan_ze_3;
cin >> xuan_ze_3;
switch (xuan_ze_3)
{
case(1):
{
tm tong_zhi_tm = *localtime(&yu_yue);
tong_zhi_tm.tm_hour = 8;
tong_zhi = mktime(&tong_zhi_tm);
dang_qian_yue_fen = 0;
break;
}
case(2):
{
tm tong_zhi_tm = *localtime(&yu_yue);
tong_zhi_tm.tm_hour = 13;
tong_zhi = mktime(&tong_zhi_tm);
dang_qian_yue_fen = 0;
break;
}
case(3):
{
time_t temp = yu_yue - 24 * 60 * 60;
tm tong_zhi_tm = *localtime(&temp);
tong_zhi_tm.tm_hour = 21;
tong_zhi = mktime(&tong_zhi_tm);
dang_qian_yue_fen = 0;
break;
}
case(4):
{
cout << "提前几分钟通知?" << endl;
int ti_qian; cin >> ti_qian;
tong_zhi = yu_yue - ti_qian * 60;
dang_qian_yue_fen = 0;
break;
}
default:
{
cout << "无关选项,请重新选择:" << endl;
system("pause");
break;
}
}
}
wofstream shu_chu;
shu_chu.imbue(locale("", LC_CTYPE));
shu_chu.open("xing_cheng.txt", ios::out | ios::app);
if (!shu_chu.is_open())
{
cout << "获取文件失败,行程记录失效。" << endl;
return;
}
shu_chu << tong_zhi << " " << yu_yue << " " << xing_cheng << endl;
shu_chu.close();
break;
}
case(2):
{
cout << endl;
wifstream jia_zai;
jia_zai.imbue(locale("", LC_CTYPE));
jia_zai.open("xing_cheng.txt", ios::in);
if (!jia_zai.is_open())
{
cout << "获取文件失败,行程显示失效。" << endl;
return;
}
time_t yu_yue, tong_zhi;
tm yu_yue_tm, tong_zhi_tm;
wstring huo_dong; int id = 1;
while (jia_zai >> tong_zhi && jia_zai >> yu_yue && jia_zai >> huo_dong)
{
cout << id << endl; id++;
yu_yue_tm = *localtime(&yu_yue);
tong_zhi_tm = *localtime(&tong_zhi);
wcout.imbue(locale("", LC_CTYPE));
wcout << L"通知时间为:" << tong_zhi_tm.tm_mon + 1 << L"月" << tong_zhi_tm.tm_mday << L"日"
<< tong_zhi_tm.tm_hour << L"时" << tong_zhi_tm.tm_min << L"分 " << endl;
wcout << L"开始时间为:" << yu_yue_tm.tm_mon + 1 << L"月" << yu_yue_tm.tm_mday << L"日"
<< yu_yue_tm.tm_hour << L"时" << yu_yue_tm.tm_min << L"分 " << endl;
wcout << L"行程:" << huo_dong << endl< Vap = an_pai_jia_zai();
if (Vap.size() == 0)
{
cout << "目前无行程。" << endl;
system("pause");
break;
}
system("pause");
break;
}
case(3):
{
cout << endl;
wifstream jia_zai;
jia_zai.imbue(locale("", LC_CTYPE));
jia_zai.open("xing_cheng.txt", ios::in);
if (!jia_zai.is_open())
{
cout << "获取文件失败,行程显示失效。" << endl;
return;
}
time_t yu_yue, tong_zhi;
tm yu_yue_tm, tong_zhi_tm;
wstring huo_dong; int id = 1;
while (jia_zai >> tong_zhi && jia_zai >> yu_yue && jia_zai >> huo_dong)
{
cout << id << endl; id++;
yu_yue_tm = *localtime(&yu_yue);
tong_zhi_tm = *localtime(&tong_zhi);
wcout.imbue(locale("", LC_CTYPE));
wcout << L"通知时间为:" << tong_zhi_tm.tm_mon + 1 << L"月" << tong_zhi_tm.tm_mday << L"日"
<< tong_zhi_tm.tm_hour << L"时" << tong_zhi_tm.tm_min << L"分 " << endl;
wcout << L"开始时间为:" << yu_yue_tm.tm_mon + 1 << L"月" << yu_yue_tm.tm_mday << L"日"
<< yu_yue_tm.tm_hour << L"时" << yu_yue_tm.tm_min << L"分 " << endl;
wcout << L"行程:" << huo_dong << endl << endl;
}
jia_zai.close();
vector Vap = an_pai_jia_zai();
if (Vap.size() == 0)
{
cout << "目前无行程。" << endl;
system("pause");
break;
}
cout << "请输入删除行程序号:" << endl;
cin >> id;
vector::iterator ddq = Vap.begin()+id-1;
Vap.erase(ddq);
geng_xin(Vap);
cout << "删除完成。"<
#include
#include
#include
using namespace std;
struct an_pai
{
time_t yu_yue, tong_zhi;
wstring xing_cheng;
int id;
};
vector an_pai_jia_zai()
{
vectorVap;
Vap.clear();
wifstream shu_ru;
shu_ru.open("xing_cheng.txt", ios::in);
shu_ru.imbue(locale("", LC_CTYPE));
an_pai ap;
int ID = 1;
while (ap.id = ID && shu_ru >> ap.tong_zhi && shu_ru >> ap.yu_yue && shu_ru >> ap.xing_cheng)
{
Vap.push_back(ap);
ID++;
}
return Vap;
}
void geng_xin(vectorVap)
{
wofstream shu_chu;
shu_chu.imbue(locale("", LC_CTYPE));
shu_chu.open("xing_cheng.txt", ios::out | ios::trunc);
if (!shu_chu.is_open())
{
cout << "获取文件失败,行程再记录失效。" << endl;
return;
}
for (int i = 0; i < Vap.size(); i++)
{
shu_chu << Vap[i].tong_zhi << " " << Vap[i].yu_yue << " " << Vap[i].xing_cheng << endl;
}
shu_chu.close();
}
void tong_zhi_pan_duan(vectorVap)
{
time_t now = time(NULL);
for (int i = 0; i < Vap.size(); i++)
{
if (now > Vap[i].tong_zhi)
{
wstring tz1_str = Vap[i].xing_cheng;
time_t temp = Vap[i].yu_yue;
tm tz2_tm = *localtime(&temp);
wchar_t tz2[6];
tz2[0] = tz2_tm.tm_hour / 10;
tz2[1] = tz2_tm.tm_hour % 10;
tz2[3] = ':';
tz2[4] = tz2_tm.tm_hour / 10;
tz2[5] = tz2_tm.tm_hour % 10;
LPCWSTR tz1_LPC = tz1_str.c_str();
wstring tz2_str(tz2);
LPCWSTR tz2_LPC = tz2_str.c_str();
MessageBox(NULL, tz1_LPC, tz1_LPC, MB_OK);
vector::iterator j = Vap.begin()+i;
Vap.erase(j);
geng_xin(Vap);
i = 0;
}
}
}
标签: