|
|
@@ -13,6 +13,17 @@ public:
|
|
|
//程序休眠X秒
|
|
|
static void my_sleep(int second);
|
|
|
|
|
|
+ static std::wstring getExePath()
|
|
|
+ {
|
|
|
+ wchar_t exeFullPath[MAX_PATH]; // Full path
|
|
|
+ std::wstring strPath = L"";
|
|
|
+
|
|
|
+ GetModuleFileName(NULL, exeFullPath, MAX_PATH);
|
|
|
+ strPath = (wstring)exeFullPath; // Get full path of the file
|
|
|
+
|
|
|
+ return strPath;
|
|
|
+ }
|
|
|
+
|
|
|
static std::wstring GetProgramDir()
|
|
|
{
|
|
|
wchar_t exeFullPath[MAX_PATH]; // Full path
|
|
|
@@ -88,5 +99,29 @@ public:
|
|
|
DWORD dwAttrib = GetFileAttributes(csPath.c_str());
|
|
|
return INVALID_FILE_ATTRIBUTES != dwAttrib;
|
|
|
}
|
|
|
+
|
|
|
+ static std::string GetVersion()
|
|
|
+ {
|
|
|
+ std::string r = "";
|
|
|
+
|
|
|
+ UINT sz = GetFileVersionInfoSize(getExePath().c_str(), 0);
|
|
|
+ if(sz != 0)
|
|
|
+ {
|
|
|
+ r.resize(sz, 0);
|
|
|
+ char* pBuf = NULL;
|
|
|
+ pBuf = new char[sz];
|
|
|
+ VS_FIXEDFILEINFO* pVsInfo;
|
|
|
+ if(GetFileVersionInfo(getExePath().c_str(), 0, sz, pBuf))
|
|
|
+ {
|
|
|
+ if(VerQueryValue(pBuf, L"\\", (void**)&pVsInfo, &sz))
|
|
|
+ {
|
|
|
+ sprintf(pBuf, "%d.%d.%d.%d", HIWORD(pVsInfo->dwFileVersionMS), LOWORD(pVsInfo->dwFileVersionMS), HIWORD(pVsInfo->dwFileVersionLS), LOWORD(pVsInfo->dwFileVersionLS));
|
|
|
+ r = pBuf;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ delete pBuf;
|
|
|
+ }
|
|
|
+ return r;
|
|
|
+ }
|
|
|
};
|
|
|
|