标签:get inf pre oid tchar nms UI 版本号 max
1 string GetMainProgInfo() 2 { 3 string strRet; 4 TCHAR szPath[MAX_PATH]; 5 GetModuleFileName(NULL,szPath,MAX_PATH); 6 7 //根据主程序路径获取版本信息 8 DWORD dwHandle = 0; 9 DWORD dwVerSize = GetFileVersionInfoSize(szPath,&dwHandle); 10 if (dwVerSize > 0) 11 { 12 BYTE* pBlock = new BYTE[dwVerSize]; 13 if (GetFileVersionInfo(szPath,0,dwVerSize,pBlock)) 14 { 15 VS_FIXEDFILEINFO* pVerinfo; 16 UINT nLen; 17 if (VerQueryValue(pBlock,"\\",(LPVOID*)&pVerinfo,&nLen)) 18 { 19 char temp[512]={0}; 20 sprintf_s(temp,"%d.%d.%d.%d", 21 HIWORD(pVerinfo->dwFileVersionMS), 22 LOWORD(pVerinfo->dwFileVersionMS), 23 HIWORD(pVerinfo->dwFileVersionLS), 24 LOWORD(pVerinfo->dwFileVersionLS)); 25 26 strRet = temp; 27 } 28 } 29 delete [] pBlock; 30 } 31 return strRet; 32 }
标签:get inf pre oid tchar nms UI 版本号 max
原文地址:http://www.cnblogs.com/brianyi/p/6483042.html