From 0c1bfb7c51038920ba465b6450150dad51c0dbbe Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Sun, 27 Jul 2025 20:10:15 +0800 Subject: [PATCH] Improve: Showing the client application version --- client/LoginServer.cpp | 39 +++++++++++++++++++++++++++++ common/commands.h | 1 + server/2015Remote/2015RemoteDlg.cpp | 6 ++--- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/client/LoginServer.cpp b/client/LoginServer.cpp index 6fa6a42..0a6f744 100644 --- a/client/LoginServer.cpp +++ b/client/LoginServer.cpp @@ -225,6 +225,44 @@ double GetMemorySizeGB() { return GB; } +#pragma comment(lib, "Version.lib") +std::string GetCurrentExeVersion() { + TCHAR filePath[MAX_PATH]; + if (GetModuleFileName(NULL, filePath, MAX_PATH) == 0) { + return "Unknown"; + } + + DWORD handle = 0; + DWORD verSize = GetFileVersionInfoSize(filePath, &handle); + if (verSize == 0) { + return "Unknown"; + } + + std::vector verData(verSize); + if (!GetFileVersionInfo(filePath, handle, verSize, verData.data())) { + return "Unknown"; + } + + VS_FIXEDFILEINFO* pFileInfo = nullptr; + UINT len = 0; + if (!VerQueryValue(verData.data(), "\\", reinterpret_cast(&pFileInfo), &len)) { + return "Unknown"; + } + + if (pFileInfo) { + DWORD major = HIWORD(pFileInfo->dwFileVersionMS); + DWORD minor = LOWORD(pFileInfo->dwFileVersionMS); + DWORD build = HIWORD(pFileInfo->dwFileVersionLS); + DWORD revision = LOWORD(pFileInfo->dwFileVersionLS); + + std::ostringstream oss; + oss << major << "." << minor << "." << build << "." << revision; + return "v" + oss.str(); + } + + return "Unknown"; +} + LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn) { LOGIN_INFOR LoginInfor; @@ -300,6 +338,7 @@ LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn) } LoginInfor.AddReserved(loc.c_str()); LoginInfor.AddReserved(pubIP.c_str()); + LoginInfor.AddReserved(GetCurrentExeVersion().c_str()); return LoginInfor; } diff --git a/common/commands.h b/common/commands.h index 1cfd379..d2730d8 100644 --- a/common/commands.h +++ b/common/commands.h @@ -733,6 +733,7 @@ enum LOGIN_RES { RES_EXPIRED_DATE = 9, // 到期日期 RES_CLIENT_LOC = 10, // 地理位置 RES_CLIENT_PUBIP = 11, // 公网地址 + RES_EXE_VERSION = 12, // EXE版本 RES_MAX, }; diff --git a/server/2015Remote/2015RemoteDlg.cpp b/server/2015Remote/2015RemoteDlg.cpp index 93a7af6..d02a2f9 100644 --- a/server/2015Remote/2015RemoteDlg.cpp +++ b/server/2015Remote/2015RemoteDlg.cpp @@ -2840,8 +2840,8 @@ void CMy2015RemoteDlg::OnListClick(NMHDR* pNMHDR, LRESULT* pResult) CString strText; std::string expired = res[RES_EXPIRED_DATE]; expired = expired.empty() ? "" : " Expired on " + expired; - strText.Format(_T("鏂囦欢璺緞: %s%s\r\n绯荤粺淇℃伅: %s 浣 %s 鏍稿績 %s GB\r\n鍚姩淇℃伅: %s %s\r\n涓婄嚎淇℃伅: %s %d %s"), - res[RES_PROGRAM_BITS].IsEmpty() ? "" : res[RES_PROGRAM_BITS] + " 浣 ", res[RES_FILE_PATH], + strText.Format(_T("鏂囦欢璺緞: %s%s %s\r\n绯荤粺淇℃伅: %s 浣 %s 鏍稿績 %s GB\r\n鍚姩淇℃伅: %s %s\r\n涓婄嚎淇℃伅: %s %d %s"), + res[RES_PROGRAM_BITS].IsEmpty() ? "" : res[RES_PROGRAM_BITS] + " 浣 ", res[RES_FILE_PATH], res[RES_EXE_VERSION], res[RES_SYSTEM_BITS], res[RES_SYSTEM_CPU], res[RES_SYSTEM_MEM], startTime, expired.c_str(), ctx->GetProtocol().c_str(), ctx->GetServerPort(), typMap[type].c_str()); @@ -2854,7 +2854,7 @@ void CMy2015RemoteDlg::OnListClick(NMHDR* pNMHDR, LRESULT* pResult) // 鍒涘缓鎻愮ず绐楀彛 m_pFloatingTip = new CWnd(); - int width = res[RES_FILE_PATH].GetLength() * 10; + int width = res[RES_FILE_PATH].GetLength() * 10 + 36; width = min(max(width, 360), 800); CRect rect(pt.x, pt.y, pt.x + width, pt.y + 80); // 瀹藉害銆侀珮搴