再爛也是自己做的,再好也是別人寫的,在此留念。
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 << "無關(guān)選項,請重新選擇:" << endl; system("pause"); break; }
}
}
}
Mu_Lu.h
#pragma once
#include
using namespace std;
class mu_lu
{
public:
void zong()
{
cout << "-------------------------" << endl;
cout << "??1.定時關(guān)機??????" << endl;
cout << "?????????????" << endl;
cout << "??2.動態(tài)壁紙??????" << endl;
cout << "?????????????" << endl;
cout << "??3.行程????????" << endl;
cout << "?????????????" << endl;
cout << "?????????????" << endl;
cout << "?????????????" << endl;
cout << "?????????????" << endl;
cout << "?????????????" << endl;
cout << "??輸入0統(tǒng)一視為退出??" << endl;
cout << "-------------------------" << endl;
}
void ding_shi_guan_ji()
{
cout << "-------------------------" << endl;
cout << "??1.關(guān)機????????" << endl;
cout << "?????????????" << endl;
cout << "??2.定時關(guān)機??????" << endl;
cout << "?????????????" << endl;
cout << "??3.重啟????????" << endl;
cout << "?????????????" << endl;
cout << "??4.定時重啟??????" << endl;
cout << "?????????????" << endl;
cout << "??5.取消定時關(guān)機/重啟??" << 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 << "行程安排需要助手處于運行狀態(tài)。" << 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 << "關(guān)機將于幾分鐘后執(zhí)行?"<> 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 << "重啟將于幾分鐘后執(zhí)行?"<> 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 << "關(guān)機/重啟取消。" << endl; break;?
}
default:
{
cout << "無關(guān)選項,請重新選擇:" << 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 << "無關(guān)選項,請重新選擇:" << 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 << "無關(guān)選項,請重新選擇:" << 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;
}
}
}
標簽: