#pragma execution_character_set("utf-8") #include "mainwindow.h" #include "qnetworkproxy.h" #include #include #include #include "psapi.h" #include #include "easylogging++.h" #define _CRTDBG_MAP_ALLOC #include #include bool isRunning(QString strName) { int i = 0; PROCESSENTRY32 pe32; pe32.dwSize = sizeof(pe32); HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hProcessSnap == INVALID_HANDLE_VALUE) { i += 0; } bool bMore = ::Process32First(hProcessSnap, &pe32); LOG(INFO) << "find process..."; while (bMore) { QString strProcessName = QString::fromWCharArray(pe32.szExeFile); // LOG(INFO) << strProcessName.toStdString(); if (strProcessName == strName) { i++; LOG(INFO) << "find DPS.exe"; } bMore = ::Process32Next(hProcessSnap, &pe32); } return (i > 1) ? true : false; } int main(int argc, char* argv[]) { QApplication a(argc, argv); if (isRunning(a.applicationFilePath().split("/").last())) { //弹窗提示进程已存在,不能重复启动 QMessageBox::about(NULL, "错误", "请勿重复运行本程序"); return -1; } a.setWindowIcon(QIcon("icon1.ico")); #ifdef DEVELOPENV QNetworkProxyFactory::setUseSystemConfiguration(false); qputenv("QTWEBENGINE_REMOTE_DEBUGGING", "8078"); #endif MainWindow w; w.resize(1600, 900); w.show(); return a.exec(); _CrtDumpMemoryLeaks(); }