From bfe14e41fa5b07771d78af4511ba18d706bc23cc Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 28 七月 2025 17:07:52 +0800
Subject: [PATCH] 1.Spooling Config功能EAP模拟测试;
---
SourceCode/Bond/BoounionPLC/BoounionPLC.cpp | 66 +++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/SourceCode/Bond/BoounionPLC/BoounionPLC.cpp b/SourceCode/Bond/BoounionPLC/BoounionPLC.cpp
index ea8cc72..1ceaee6 100644
--- a/SourceCode/Bond/BoounionPLC/BoounionPLC.cpp
+++ b/SourceCode/Bond/BoounionPLC/BoounionPLC.cpp
@@ -5,11 +5,63 @@
#include "stdafx.h"
#include "BoounionPLC.h"
#include "BoounionPLCDlg.h"
+#include "HorizontalLine.h"
+#include "VerticalLine.h"
+
+#include <DbgHelp.h>
+#pragma comment(lib, "DbgHelp.lib")
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
+LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS* pExceptionInfo) {
+ SYSTEMTIME st;
+ GetLocalTime(&st);
+
+ // 获取当前程序运行目录
+ char szAppPath[MAX_PATH];
+ GetModuleFileName(NULL, szAppPath, MAX_PATH);
+ std::string strCurrentDir = szAppPath;
+ size_t lastSlash = strCurrentDir.find_last_of("\\/");
+ strCurrentDir = strCurrentDir.substr(0, lastSlash);
+
+ // 检查Temp文件夹
+ struct stat buffer;
+ std::string strFullTempPath = strCurrentDir + "\\Temp";
+ if (stat(strFullTempPath.c_str(), &buffer) != 0) {
+ if (!CreateDirectory(strFullTempPath.c_str(), NULL)) {
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+ }
+
+ // 构建文件名
+ char szFileName[MAX_PATH];
+ snprintf(szFileName, MAX_PATH, "\\BoounionPLC_%04d%02d%02d_%02d%02d%02d.dmp",
+ st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
+
+ // 写入DMP文件
+ std::string strFullPath = strFullTempPath + szFileName;
+ HANDLE hFile = CreateFile(strFullPath.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ MINIDUMP_EXCEPTION_INFORMATION dumpInfo;
+ dumpInfo.ExceptionPointers = pExceptionInfo;
+ dumpInfo.ThreadId = GetCurrentThreadId();
+ dumpInfo.ClientPointers = TRUE;
+
+ // 写入dump文件
+ BOOL success = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpWithFullMemory, &dumpInfo, NULL, NULL);
+ CloseHandle(hFile);
+
+ if (success) {
+ CString strMsg;
+ strMsg.Format(_T("Software crashes. Dump file: %s"), strFullPath.c_str());
+ AfxMessageBox(strMsg);
+ }
+ }
+
+ return EXCEPTION_EXECUTE_HANDLER;
+}
// CBoounionPLCApp
@@ -27,6 +79,7 @@
// TODO: 在此处添加构造代码,
// 将所有重要的初始化放置在 InitInstance 中
+ SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
}
@@ -83,6 +136,11 @@
m_model.setWorkDir((LPTSTR)(LPCTSTR)m_strAppDir);
+ // gdi+
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
+
+
CString strIniFile;
strIniFile.Format(_T("%s\\BoounionPLCconfiguration.ini"), (LPTSTR)(LPCTSTR)m_strAppDir);
int plcTimeout = GetPrivateProfileInt("PLC", "Timeout", 700, strIniFile);
@@ -102,6 +160,11 @@
}
+ // 控件注册
+ CHorizontalLine::RegisterWndClass();
+ CVerticalLine::RegisterWndClass();
+
+
CBoounionPLCDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
@@ -134,6 +197,9 @@
int CBoounionPLCApp::ExitInstance()
{
+ // gdi+
+ Gdiplus::GdiplusShutdown(m_gdiplusToken);
+
m_model.term();
RX_Term();
MCL_Term();
--
Gitblit v1.9.3