|
@@ -42,15 +42,14 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
|
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
|
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
|
|
|
|
|
- // TODO: 在此放置代码。
|
|
|
MSG msg;
|
|
|
HACCEL hAccelTable;
|
|
|
|
|
|
- // 初始化全局字符串
|
|
|
+ // 初始化全局字符串
|
|
|
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
|
|
LoadString(hInstance, IDC_TEST, szWindowClass, MAX_LOADSTRING);
|
|
|
MyRegisterClass(hInstance);
|
|
|
-
|
|
|
+ Sleep(200);
|
|
|
// 执行应用程序初始化:
|
|
|
if (!InitInstance (hInstance, nCmdShow))
|
|
|
{
|
|
@@ -114,6 +113,12 @@ BOOL ExistsFileA(LPCSTR lpFilePath)
|
|
|
return (dwRet != INVALID_FILE_ATTRIBUTES) && !(dwRet & FILE_ATTRIBUTE_DIRECTORY);
|
|
|
}
|
|
|
|
|
|
+BOOL ExistsDirA(LPCSTR lpDirPath)
|
|
|
+{
|
|
|
+ DWORD dwRet = GetFileAttributesA(lpDirPath);
|
|
|
+ return (dwRet != INVALID_FILE_ATTRIBUTES) && (dwRet & FILE_ATTRIBUTE_DIRECTORY);
|
|
|
+}
|
|
|
+
|
|
|
UINT GetErrorMessage(CString& retMessage, LPCTSTR lpDefault, DWORD error = GetLastError())
|
|
|
{
|
|
|
if (error == 0) {
|
|
@@ -152,8 +157,9 @@ int GetVersion(char** pVersion)
|
|
|
sprintf_s(szFilePath, MAX_PATH,"%s\\active.txt", strDir.c_str());
|
|
|
if (!ExistsFileA(szFilePath)) {
|
|
|
CString strText;
|
|
|
- strText.Format("[RTAXXXX] 版本文件active.txt不存在,请检查应用程序的完整性!版本文件路径:%s", szFilePath);
|
|
|
+ strText.Format("[RTA0031] 版本文件 active.txt 不存在,请重新安装程序版本!(文件路径:%s)", szFilePath);
|
|
|
MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
char cVer[MAX_PATH] = {0};
|
|
@@ -166,24 +172,24 @@ int GetVersion(char** pVersion)
|
|
|
strVersionTxt.Trim();
|
|
|
if (strVersionTxt.IsEmpty()) {
|
|
|
CString strText;
|
|
|
- strText.Format("[RTAXXXX] 版本文件active.txt内容为空,请检查应用程序的完整性!版本文件路径:%s", szFilePath);
|
|
|
+ strText.Format("[RTA0032] 版本文件 active.txt 内容为空,请重新安装程序版本!(文件路径:%s)", szFilePath);
|
|
|
MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
infile.close();
|
|
|
return 0;
|
|
|
}
|
|
|
std::regex reg("^\\d+\\.\\d+\\.\\d+\\.\\d+$");
|
|
|
- std::string strVerion(cVer);
|
|
|
+ std::string strVerion(strVersionTxt.GetString());
|
|
|
/** 要不要加正则表达式校验待定,目前没有加 [Gifur@2025516]*/
|
|
|
if (TRUE || std::regex_match(strVerion, reg))
|
|
|
{
|
|
|
- memcpy_s(*pVersion, MAX_PATH, cVer, MAX_PATH);
|
|
|
+ memcpy_s(*pVersion, MAX_PATH, strVersionTxt.GetString(), MAX_PATH);
|
|
|
infile.close();
|
|
|
return 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CString strText;
|
|
|
- strText.Format("[RTAXXXX] 版本文件active.txt内容不符合X.Y.Z.W格式,请检查应用程序的完整性!\r\n版本文件路径:%s\r\n当前内容为:%s"
|
|
|
+ strText.Format("[RTAXXXX] 版本文件 active.txt 内容不符合 X.Y.Z.W 格式,请检查应用程序的完整性!\r\n版本文件路径:%s\r\n当前内容为:%s"
|
|
|
, szFilePath, cVer);
|
|
|
MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
infile.close();
|
|
@@ -193,7 +199,7 @@ int GetVersion(char** pVersion)
|
|
|
else
|
|
|
{
|
|
|
CString strText;
|
|
|
- strText.Format("[RTAXXXX] 版本文件active.txt内容为空,请检查应用程序的完整性!版本文件路径:%s", szFilePath);
|
|
|
+ strText.Format("[RTA0032] 版本文件 active.txt 内容为空,请重新安装程序版本!(文件路径:%s)", szFilePath);
|
|
|
MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
infile.close();
|
|
|
return 0;
|
|
@@ -201,7 +207,7 @@ int GetVersion(char** pVersion)
|
|
|
}
|
|
|
else {
|
|
|
CString strText;
|
|
|
- strText.Format("[RTAXXXX] 版本文件active.txt打开失败,请联系分行IT或厂商排查!版本文件路径:%s", szFilePath);
|
|
|
+ strText.Format("[RTA0033] 版本文件 active.txt 打开失败,请联系分行IT或厂商排查!(文件路径:%s)", szFilePath);
|
|
|
MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
return 0;
|
|
|
}
|
|
@@ -224,6 +230,24 @@ BOOL GetSpShellPath(char** pPath)
|
|
|
|
|
|
if(!GetVersion(&pVer))
|
|
|
{
|
|
|
+ if (NULL != pVer)
|
|
|
+ {
|
|
|
+ free(pVer);
|
|
|
+ pVer = NULL;
|
|
|
+ }
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+ memset(szFileName, 0, sizeof(szFileName));
|
|
|
+ sprintf_s(szFileName, MAX_PATH, "%s\\%s", strDir.c_str(), pVer);
|
|
|
+ if (!ExistsDirA(szFileName)) {
|
|
|
+ CString strText;
|
|
|
+ strText.Format("[RTA0034] 版本文件夹 [%s] 不存在,请重新安装程序版本!(文件夹路径:%s)",pVer, szFileName);
|
|
|
+ MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
+ if (NULL != pVer)
|
|
|
+ {
|
|
|
+ free(pVer);
|
|
|
+ pVer = NULL;
|
|
|
+ }
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
@@ -238,23 +262,12 @@ BOOL GetSpShellPath(char** pPath)
|
|
|
|
|
|
if (!ExistsFileA(*pPath)) {
|
|
|
CString strText;
|
|
|
- strText.Format("[RTAXXXX] 应用程序执行文件SpShell.exe不存在,请检查应用程序的完整性!执行文件路径:%s", *pPath);
|
|
|
+ strText.Format("[RTA0035] 程序执行文件 SpShell.exe 不存在,请重新安装程序版本!(文件路径:%s)", *pPath);
|
|
|
MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
|
- ifstream shellFile(*pPath);
|
|
|
- if(shellFile)
|
|
|
- {
|
|
|
- return TRUE;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- CString strText;
|
|
|
- strText.Format("[RTAXXXX] 应用程序执行文件SpShell.exe不存在,请检查应用程序的完整性!执行文件路径:%s", *pPath);
|
|
|
- MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
+ return TRUE;
|
|
|
}
|
|
|
|
|
|
BOOL Execute(const char* cExeName)
|
|
@@ -272,7 +285,7 @@ BOOL Execute(const char* cExeName)
|
|
|
char szDefault[128];
|
|
|
sprintf_s(szDefault, "错误描述:%u", dwError);
|
|
|
GetErrorMessage(strError, szDefault, dwError);
|
|
|
- strText.Format("[RTAXXXX] 运行应用程序执行文件SpShell.exe失败,请联系分行IT或厂商排查!\r\n%s\r\n执行文件路径:%s", strError.GetBuffer(), cExeName);
|
|
|
+ strText.Format("[RTA0036] 执行应用程序文件 SpShell.exe 失败,请联系分行IT或厂商排查!(文件路径:%s)\r\n\r\n%s", cExeName, strError.GetBuffer());
|
|
|
MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
return FALSE;
|
|
|
}
|
|
@@ -318,7 +331,7 @@ int checkActiveTxtAttr()
|
|
|
const auto nPosVtm = strRunVtmPath.find("\\version\\VTM.exe");
|
|
|
if(nPosVtm == -1)
|
|
|
{
|
|
|
- MessageBoxA(NULL,"[RTAXXXX] VTM.exe 不在规定路径下运行,请按规范安装版本!", ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
+ MessageBoxA(NULL,"[RTA0030] VTM.exe 不在规定路径下运行,请重新安装程序版本!", ERROR_TITILE, MB_OK | MB_ICONERROR);
|
|
|
return -1;
|
|
|
}
|
|
|
const int nPos = strRunVtmPath.find_last_of("\\");
|
|
@@ -326,13 +339,14 @@ int checkActiveTxtAttr()
|
|
|
CString strActiveTxtPath=strVersionDir.c_str();//+"active.txt";
|
|
|
strActiveTxtPath +="\\";
|
|
|
strActiveTxtPath +="active.txt";
|
|
|
-
|
|
|
- CFileStatus rStatus;
|
|
|
- CFile::GetStatus(strActiveTxtPath,rStatus);//获得文件的属性设置
|
|
|
- //如果文件为只读的,将只读属性去掉
|
|
|
- if(rStatus.m_attribute&CFile::readOnly){
|
|
|
- rStatus.m_attribute=rStatus.m_attribute & 0x3E ;
|
|
|
- CFile::SetStatus(strActiveTxtPath, rStatus );//更改文件的属性设置
|
|
|
+ if (ExistsFileA(strActiveTxtPath)) {
|
|
|
+ CFileStatus rStatus;
|
|
|
+ CFile::GetStatus(strActiveTxtPath, rStatus);//获得文件的属性设置
|
|
|
+ //如果文件为只读的,将只读属性去掉
|
|
|
+ if (rStatus.m_attribute & CFile::readOnly) {
|
|
|
+ rStatus.m_attribute = rStatus.m_attribute & 0x3E;
|
|
|
+ CFile::SetStatus(strActiveTxtPath, rStatus);//更改文件的属性设置
|
|
|
+ }
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
@@ -458,28 +472,22 @@ void GetDisplayScale()
|
|
|
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|
|
{
|
|
|
// 校正active.txt的属性
|
|
|
- if (0 != checkActiveTxtAttr())
|
|
|
- return FALSE;
|
|
|
-
|
|
|
- //启动框架
|
|
|
- if (RunSpshell()) {
|
|
|
+ if (0 == checkActiveTxtAttr() && RunSpshell()) {
|
|
|
HideTaskBar(TRUE);
|
|
|
}
|
|
|
|
|
|
hInst = hInstance; // 将实例句柄存储在全局变量中
|
|
|
|
|
|
- /*hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
|
|
- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
|
|
|
-
|
|
|
- if (!hWnd)
|
|
|
- {
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
+ //HWND hWnd = CreateWindowA(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
|
|
+ //CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
|
|
|
|
|
|
- ShowWindow(hWnd, nCmdShow);
|
|
|
- UpdateWindow(hWnd);*/
|
|
|
- //MessageBoxA(NULL,"Hello",NULL,0);
|
|
|
+ //if (!hWnd)
|
|
|
+ //{
|
|
|
+ //return FALSE;
|
|
|
+ //}
|
|
|
|
|
|
+ //ShowWindow(hWnd, nCmdShow);
|
|
|
+ //UpdateWindow(hWnd);
|
|
|
return FALSE;
|
|
|
}
|
|
|
|