替换程序的原Update,避免更新检查

在使用电脑的过程常常会碰到一些程序的Update程序频繁联网检查更新,或者频繁弹出。

为了节省系统资源,避免更新弹出,洗了一个能记录跟新唤醒和不执行任何操作的程序,使用时把程序原Update成其他名(例如加一个1或者backup),用这个替换呈程序的原Update文件名。之后被唤起时不弹出黑框,会建立一个Update.log文本,记录程序每次被唤醒的时间,然后自动结束。

源代码如下:

#include <iostream>#include <fstream>
#include <ctime>
#include <windows.h>
#pragma warning(disable : 4996);
#pragma comment(linker, "/subsystem:"windows" /entry:"mainCRTStartup"");
using namespace std;


int main()
{
    ShowWindow(GetConsoleWindow(), SW_HIDE);
    std::time_t now = std::time(nullptr); // 获取当前时间(以秒为单位的时间戳)
    char buffer[26];
    std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S",std::localtime(&now)); // 将时间格式化为字符串

    std::string currentTime = std::string(buffer); // 赋值给字符串
    ofstream file1("Update.log", ios::app);
    file1 << "这是一次更新" << currentTime <<endl;
    file1.close();
}
© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
评论 共31条

请登录后发表评论