1 CString CQwerApp::IS_GetAppVersion(char *AppName) 2 { 3 ////需要加上version.lib在link里 4 CString AppVersion; 5 //AppVersion=IS_GetAppCreateTime(AppName); 6 7 DWORD RessourceVersionInfoSize; 8 DWORD JustAJunkVariabel; 9 char* VersionInfoPtr; 10 struct LANGANDCODEPAGE { 11 WORD wLanguage; 12 WORD wCodePage; 13 } *TranslationPtr; 14 char* InformationPtr; 15 UINT VersionInfoSize; 16 char VersionValue[255]; 17 18 RessourceVersionInfoSize=GetFileVersionInfoSize(AppName,&JustAJunkVariabel); 19 if(0!=RessourceVersionInfoSize) 20 { 21 VersionInfoPtr=new char[RessourceVersionInfoSize]; 22 if(GetFileVersionInfo(AppName,0,RessourceVersionInfoSize,VersionInfoPtr)) 23 { 24 if(!VerQueryValue( 25 VersionInfoPtr, 26 TEXT("VarFileInfo\Translation"), 27 (LPVOID*)&TranslationPtr, 28 &VersionInfoSize)) 29 { 30 delete[] VersionInfoPtr; 31 return AppVersion; 32 } 33 } 34 35 // retrieve File Description 36 wsprintf(VersionValue, 37 TEXT(""), 38 TranslationPtr[0].wLanguage, 39 TranslationPtr[0].wCodePage); 40 41 if(!VerQueryValue( 42 VersionInfoPtr, 43 VersionValue, 44 (LPVOID*)&InformationPtr, 45 &VersionInfoSize)) 46 { 47 delete[] VersionInfoPtr; 48 return AppVersion; 49 } 50 if(strlen(InformationPtr)>0) //Not Null 51 { 52 AppVersion=CString(InformationPtr); 53 } 54 delete[] VersionInfoPtr; 55 } 56 return AppVersion; 57 58 }