From 2be286ac19bf2bb00e27f556e8b2cc292a58bd09 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期四, 08 一月 2026 18:48:59 +0800
Subject: [PATCH] 1.EAP状态继续实现,已在左侧加入相关按钮
---
SourceCode/Bond/SGMeasurement/SGMeasurement.cpp | 86 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 77 insertions(+), 9 deletions(-)
diff --git a/SourceCode/Bond/SGMeasurement/SGMeasurement.cpp b/SourceCode/Bond/SGMeasurement/SGMeasurement.cpp
index 475924d..eeeead9 100644
--- a/SourceCode/Bond/SGMeasurement/SGMeasurement.cpp
+++ b/SourceCode/Bond/SGMeasurement/SGMeasurement.cpp
@@ -1,4 +1,4 @@
-
+锘�
// SGMeasurement.cpp: 瀹氫箟搴旂敤绋嬪簭鐨勭被琛屼负銆�
//
@@ -7,10 +7,61 @@
#include "SGMeasurement.h"
#include "SGMeasurementDlg.h"
+#include <DbgHelp.h>
+#pragma comment(lib, "DbgHelp.lib")
+
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
+LONG WINAPI MyUnhandledExceptionFilter(EXCEPTION_POINTERS* pExceptionInfo)
+{
+ // 鑾峰彇褰撳墠绋嬪簭鐩綍
+ TCHAR szAppPath[MAX_PATH] = { 0 };
+ ::GetModuleFileName(NULL, szAppPath, MAX_PATH);
+ PathRemoveFileSpec(szAppPath);
+
+ // 鏋勯�� Temp 鏂囦欢澶硅矾寰�
+ CString strTempPath;
+ strTempPath.Format(_T("%s\\Temp"), szAppPath);
+ CreateDirectory(strTempPath, NULL);
+
+ // 鐢熸垚甯︽椂闂存埑鐨� Dump 鏂囦欢鍚�
+ SYSTEMTIME st;
+ GetLocalTime(&st);
+
+ CString strDumpFile;
+ strDumpFile.Format(
+ _T("%s\\SG_%04d%02d%02d_%02d%02d%02d.dmp"),
+ strTempPath,
+ st.wYear, st.wMonth, st.wDay,
+ st.wHour, st.wMinute, st.wSecond
+ );
+
+ // 鎵撳紑 dump 鏂囦欢
+ HANDLE hFile = CreateFile(strDumpFile, 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);
+ }
+
+ return EXCEPTION_EXECUTE_HANDLER;
+}
// CSGMeasurementApp
@@ -51,6 +102,18 @@
CWinApp::InitInstance();
+ // 鍞竴瀹炰緥杩愯妫�娴�
+ m_hMutex = ::CreateMutex(NULL, FALSE, _T("MutexEdgeInspector_App"));
+ if (m_hMutex != NULL) {
+ if (::GetLastError() == ERROR_ALREADY_EXISTS) {
+ AfxMessageBox(_T("The Program is already running. Exit this Program."), MB_OK | MB_ICONERROR);
+ return FALSE;
+ }
+ }
+
+ // 璁剧疆鏈鐞嗗紓甯歌繃婊ゅ櫒锛屾崟鑾峰穿婧冨苟鐢熸垚 Dump 鏂囦欢
+ SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
+
// 鍒濆鍖� MFC RichEdit 鎺т欢
AfxInitRichEdit2();
@@ -75,23 +138,19 @@
CSGMeasurementDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
+ if (nResponse == IDOK) {
// TODO:鈥滅‘瀹氣�濇潵鍏抽棴瀵硅瘽妗嗙殑浠g爜
}
- else if (nResponse == IDCANCEL)
- {
+ else if (nResponse == IDCANCEL) {
// TODO:鈥滃彇娑堚�濇潵鍏抽棴瀵硅瘽妗嗙殑浠g爜
}
- else if (nResponse == -1)
- {
+ else if (nResponse == -1) {
TRACE(traceAppMsg, 0, "璀﹀憡: 瀵硅瘽妗嗗垱寤哄け璐ワ紝搴旂敤绋嬪簭灏嗘剰澶栫粓姝€�俓n");
TRACE(traceAppMsg, 0, "璀﹀憡: 濡傛灉鎮ㄥ湪瀵硅瘽妗嗕笂浣跨敤 MFC 鎺т欢锛屽垯鏃犳硶 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS銆俓n");
}
// 鍒犻櫎涓婇潰鍒涘缓鐨� shell 绠$悊鍣ㄣ��
- if (pShellManager != nullptr)
- {
+ if (pShellManager != nullptr) {
delete pShellManager;
}
@@ -101,4 +160,13 @@
// 鐢变簬瀵硅瘽妗嗗凡鍏抽棴锛屾墍浠ュ皢杩斿洖 FALSE 浠ヤ究閫�鍑哄簲鐢ㄧ▼搴忥紝鑰屼笉鏄惎鍔ㄥ簲鐢ㄧ▼搴忕殑娑堟伅娉点��
return FALSE;
+}
+
+int CSGMeasurementApp::ExitInstance()
+{
+ if (m_hMutex) {
+ CloseHandle(m_hMutex);
+ m_hMutex = nullptr;
+ }
+ return CWinApp::ExitInstance();
}
\ No newline at end of file
--
Gitblit v1.9.3