Improve: Showing the client application version
This commit is contained in:
@@ -225,6 +225,44 @@ double GetMemorySizeGB() {
|
|||||||
return GB;
|
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<BYTE> verData(verSize);
|
||||||
|
if (!GetFileVersionInfo(filePath, handle, verSize, verData.data())) {
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
VS_FIXEDFILEINFO* pFileInfo = nullptr;
|
||||||
|
UINT len = 0;
|
||||||
|
if (!VerQueryValue(verData.data(), "\\", reinterpret_cast<LPVOID*>(&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 GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn)
|
||||||
{
|
{
|
||||||
LOGIN_INFOR LoginInfor;
|
LOGIN_INFOR LoginInfor;
|
||||||
@@ -300,6 +338,7 @@ LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn)
|
|||||||
}
|
}
|
||||||
LoginInfor.AddReserved(loc.c_str());
|
LoginInfor.AddReserved(loc.c_str());
|
||||||
LoginInfor.AddReserved(pubIP.c_str());
|
LoginInfor.AddReserved(pubIP.c_str());
|
||||||
|
LoginInfor.AddReserved(GetCurrentExeVersion().c_str());
|
||||||
|
|
||||||
return LoginInfor;
|
return LoginInfor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -733,6 +733,7 @@ enum LOGIN_RES {
|
|||||||
RES_EXPIRED_DATE = 9, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
RES_EXPIRED_DATE = 9, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
RES_CLIENT_LOC = 10, // <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
RES_CLIENT_LOC = 10, // <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
RES_CLIENT_PUBIP = 11, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
RES_CLIENT_PUBIP = 11, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||||
|
RES_EXE_VERSION = 12, // EXE<58>汾
|
||||||
RES_MAX,
|
RES_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2840,8 +2840,8 @@ void CMy2015RemoteDlg::OnListClick(NMHDR* pNMHDR, LRESULT* pResult)
|
|||||||
CString strText;
|
CString strText;
|
||||||
std::string expired = res[RES_EXPIRED_DATE];
|
std::string expired = res[RES_EXPIRED_DATE];
|
||||||
expired = expired.empty() ? "" : " Expired on " + expired;
|
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"),
|
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_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(),
|
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());
|
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();
|
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);
|
width = min(max(width, 360), 800);
|
||||||
CRect rect(pt.x, pt.y, pt.x + width, pt.y + 80); // 宽度、高度
|
CRect rect(pt.x, pt.y, pt.x + width, pt.y + 80); // 宽度、高度
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user