|
@@ -1,6 +1,8 @@
|
|
#include "StdAfx.h"
|
|
#include "StdAfx.h"
|
|
#include "Global.h"
|
|
#include "Global.h"
|
|
|
|
|
|
|
|
+#define VLEN 10
|
|
|
|
+
|
|
namespace GLOBAL
|
|
namespace GLOBAL
|
|
{
|
|
{
|
|
TCHAR g_szModulePath[MAX_PATH] = _T(""); // 软件目录;
|
|
TCHAR g_szModulePath[MAX_PATH] = _T(""); // 软件目录;
|
|
@@ -145,12 +147,12 @@ namespace GLOBAL
|
|
return nPassCount;
|
|
return nPassCount;
|
|
strLevel = listStr.GetNext(pos);
|
|
strLevel = listStr.GetNext(pos);
|
|
|
|
|
|
- TCHAR szDist[5][5] = {0};
|
|
|
|
- TCHAR szLevel[5][5] = {0};
|
|
|
|
|
|
+ TCHAR szDist[5][VLEN] = {0};
|
|
|
|
+ TCHAR szLevel[5][VLEN] = {0};
|
|
|
|
|
|
- if (_stscanf_s(strDist.GetString(), _T("%*[^=]=%[^,],%[^,],%[^,],%[^,],%s"), szDist[0], 5, szDist[1], 5, szDist[2], 5, szDist[3], 5, szDist[4], 5) == 5 )
|
|
|
|
|
|
+ if (_stscanf_s(strDist.GetString(), _T("%*[^=]=%[^,],%[^,],%[^,],%[^,],%s"), szDist[0], VLEN, szDist[1], VLEN, szDist[2], VLEN, szDist[3], VLEN, szDist[4], VLEN) == 5 )
|
|
{
|
|
{
|
|
- if (_stscanf_s(strLevel.GetString(), _T("%*[^=]=%[^,],%[^,],%[^,],%[^,],%s"), szLevel[0], 5, szLevel[1], 5, szLevel[2], 5, szLevel[3], 5, szLevel[4], 5) == 5 )
|
|
|
|
|
|
+ if (_stscanf_s(strLevel.GetString(), _T("%*[^=]=%[^,],%[^,],%[^,],%[^,],%s"), szLevel[0], VLEN, szLevel[1], VLEN, szLevel[2], VLEN, szLevel[3], VLEN, szLevel[4], VLEN) == 5 )
|
|
{
|
|
{
|
|
std::bitset<5> bitDist(0);
|
|
std::bitset<5> bitDist(0);
|
|
std::bitset<5> bitLevel(0);
|
|
std::bitset<5> bitLevel(0);
|
|
@@ -165,9 +167,7 @@ namespace GLOBAL
|
|
bitLevel[i] = (nValue > 25) ? 1 : 0;
|
|
bitLevel[i] = (nValue > 25) ? 1 : 0;
|
|
}
|
|
}
|
|
|
|
|
|
- dprintf(_T("dist=[%s][%s][%s][%s][%s],[%s],[%ld]"), szDist[0],szDist[1],szDist[2],szDist[3],szDist[4], bitDist.to_string().c_str(), bitDist.to_ulong());
|
|
|
|
- dprintf(_T("level=[%s][%s][%s][%s][%s],[%s],[%ld]"), szLevel[0],szLevel[1],szLevel[2],szLevel[3],szLevel[4], bitLevel.to_string().c_str(), bitLevel.to_ulong());
|
|
|
|
-
|
|
|
|
|
|
+
|
|
int nDistValue = bitDist.to_ulong();
|
|
int nDistValue = bitDist.to_ulong();
|
|
int nLevelValue = bitLevel.to_ulong();
|
|
int nLevelValue = bitLevel.to_ulong();
|
|
if ( (nDistValue & nLevelValue) > 0 )
|
|
if ( (nDistValue & nLevelValue) > 0 )
|
|
@@ -177,9 +177,20 @@ namespace GLOBAL
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- dprintf("FAIL");
|
|
|
|
|
|
+ dprintf(_T("dist=[%s][%s][%s][%s][%s],[%s],[%ld]"), szDist[0],szDist[1],szDist[2],szDist[3],szDist[4], bitDist.to_string().c_str(), bitDist.to_ulong());
|
|
|
|
+ dprintf(_T("level=[%s][%s][%s][%s][%s],[%s],[%ld]"), szLevel[0],szLevel[1],szLevel[2],szLevel[3],szLevel[4], bitLevel.to_string().c_str(), bitLevel.to_ulong());
|
|
|
|
+
|
|
|
|
+ dprintf("FAIL,%s,%s", bitDist.to_string().c_str(), bitLevel.to_string().c_str());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ dprintf("失败:%s", strLevel.GetString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ dprintf("失败:%s", strDist.GetString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -215,4 +226,66 @@ namespace GLOBAL
|
|
|
|
|
|
return FALSE;
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
|
|
|
|
+ {
|
|
|
|
+ switch (uMsg)
|
|
|
|
+ {
|
|
|
|
+ case BFFM_INITIALIZED:
|
|
|
|
+ SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)GLOBAL::g_szModulePath);
|
|
|
|
+ break;
|
|
|
|
+ case BFFM_SELCHANGED:
|
|
|
|
+ {
|
|
|
|
+ TCHAR szFileName[MAX_PATH];
|
|
|
|
+ LPITEMIDLIST pidlCurrent = (LPITEMIDLIST)lp;
|
|
|
|
+ SHGetPathFromIDList(pidlCurrent, szFileName);
|
|
|
|
+ SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szFileName);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ // 这个不能让默认目录为桌面;
|
|
|
|
+ // case BFFM_INITIALIZED:
|
|
|
|
+ // {
|
|
|
|
+ // // WParam is TRUE since you are passing a path.
|
|
|
|
+ // // It would be FALSE if you were passing a pidl.
|
|
|
|
+ // TCHAR szDir[MAX_PATH] = { 0 };
|
|
|
|
+ // GetCurrentDirectory(sizeof(szDir) / sizeof(TCHAR), szDir);
|
|
|
|
+ // SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szDir);
|
|
|
|
+ // }
|
|
|
|
+ // break;
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BOOL GetFilePath(OUT TCHAR *FilePath, IN HWND hParentWnd, IN TCHAR* InstructionString, IN UINT ulFlags)
|
|
|
|
+ {
|
|
|
|
+ BROWSEINFO bInfo;
|
|
|
|
+ LPITEMIDLIST pidl, pidlDesktop;
|
|
|
|
+ ZeroMemory((PVOID)&bInfo, sizeof(BROWSEINFO));
|
|
|
|
+
|
|
|
|
+ HRESULT hr = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidlDesktop);
|
|
|
|
+ if ( hr != S_OK )
|
|
|
|
+ {
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bInfo.pidlRoot = pidlDesktop;
|
|
|
|
+ bInfo.hwndOwner = hParentWnd;
|
|
|
|
+ bInfo.pszDisplayName = FilePath;
|
|
|
|
+ bInfo.lpszTitle = InstructionString;
|
|
|
|
+ bInfo.ulFlags = ulFlags;
|
|
|
|
+ bInfo.lpfn = BrowseCallbackProc;
|
|
|
|
+ bInfo.lParam = 0;
|
|
|
|
+
|
|
|
|
+ if ((pidl = ::SHBrowseForFolder(&bInfo)) == NULL)
|
|
|
|
+ {
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (::SHGetPathFromIDList(pidl, FilePath) == FALSE)
|
|
|
|
+ {
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return TRUE;
|
|
|
|
+ }
|
|
};
|
|
};
|