main.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "mainwidget.h"
  2. #include <QtWidgets/QApplication>
  3. #include <qmessagebox.h>
  4. #include <QSharedMemory>
  5. #include <QFile>
  6. #include "../Util/Util.h"
  7. #include <QProcess>
  8. #include <QJsonObject>
  9. #include <QSettings>
  10. #include <QJsonArray>
  11. #include <QJsonDocument>
  12. #include <QMessageBox>
  13. #include <QSharedMemory>
  14. #include "QFontDatabase.h"
  15. #include "QTextCodec.h"
  16. #include "qfileinfo.h"
  17. #include <QNetworkAccessManager>
  18. #include <QNetworkRequest>
  19. #include <QNetworkReply>
  20. #include "updatedlg.h"
  21. int main(int argc, char *argv[])
  22. {
  23. QApplication a(argc, argv);
  24. QSharedMemory shared_memory;
  25. shared_memory.setKey("mutex_homework_unhandle");
  26. if (shared_memory.attach())
  27. {
  28. shared_memory.lock();
  29. *(char *)shared_memory.data() = 1;
  30. shared_memory.unlock();
  31. QMessageBox::information(NULL, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("程序已经运行!"));
  32. return 0;
  33. }
  34. shared_memory.create(1);
  35. wstring strFilePath;
  36. GetModuleDir(strFilePath);
  37. strFilePath.append(L"index.db3");
  38. QFile db_file(QString::fromStdWString(strFilePath));
  39. db_file.open(QIODevice::ReadOnly);
  40. int _length = db_file.size();
  41. db_file.close();
  42. if (_length == 0)
  43. {
  44. QMessageBox::information(NULL, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("本地配置未生成,请开启监控程序后再试!"));
  45. return 0;
  46. }
  47. a.setWindowIcon(QIcon(":/CHJUnHandle/Resources/exe.ico"));
  48. MainWidget w;
  49. w.show();
  50. return a.exec();
  51. }