DPS/DataPlatform/main.cpp

66 lines
1.4 KiB
C++

#pragma execution_character_set("utf-8")
#include "mainwindow.h"
#include "qnetworkproxy.h"
#include <QApplication>
#include <windows.h>
#include <TlHelp32.h>
#include "psapi.h"
#include <Qmessagebox.h>
#include "easylogging++.h"
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
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::fromLocal8Bit(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();
}