mark一下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
char* szFileName = "C:\\windows\\system32\\cmd.exe"; DWORD dwSize = GetFileVersionInfoSize(szFileName,NULL); LPVOID pBlock = malloc(dwSize); GetFileVersionInfo(szFileName,0,dwSize,pBlock); char* pVerValue = NULL; UINT nSize = 0; VerQueryValue(pBlock,TEXT( "\\VarFileInfo\\Translation"), (LPVOID*)&pVerValue,&nSize); CString strSubBlock,strTranslation,strTemp; strTemp.Format( "000%x",*((unsigned short int *)pVerValue)); strTranslation = strTemp.Right(4); strTemp.Format( "000%x",*((unsigned short int *)&pVerValue[2])); strTranslation += strTemp.Right(4); //080404b0为中文,040904E4为英文 MessageBox(strTranslation); //文件描述 strSubBlock.Format("\\StringFileInfo\\%s\\FileDescription",strTranslation); VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize); strSubBlock.ReleaseBuffer(); strTemp.Format( "文件描述: %s ",pVerValue); AfxMessageBox(strTemp); //内部名称 strSubBlock.Format("\\StringFileInfo\\%s\\InternalName",strTranslation); VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize); strSubBlock.ReleaseBuffer(); strTemp.Format( "内部名称: %s ",pVerValue); AfxMessageBox(strTemp); //合法版权 strSubBlock.Format("\\StringFileInfo\\%s\\LegalTradeMarks",strTranslation); VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize); strSubBlock.ReleaseBuffer(); strTemp.Format( "合法版权: %s ",pVerValue); AfxMessageBox(strTemp); //原始文件名 strSubBlock.Format("\\StringFileInfo\\%s\\OriginalFileName",strTranslation); VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize); strSubBlock.ReleaseBuffer(); strTemp.Format( "原始文件名: %s ",pVerValue); AfxMessageBox(strTemp); //产品名称 strSubBlock.Format("\\StringFileInfo\\%s\\ProductName",strTranslation); VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize); strSubBlock.ReleaseBuffer(); strTemp.Format("产品名称: %s ",pVerValue); AfxMessageBox(strTemp); //产品版本 strSubBlock.Format("\\StringFileInfo\\%s\\ProductVersion",strTranslation); VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize); strSubBlock.ReleaseBuffer(); strTemp.Format("产品版本: %s ",pVerValue); AfxMessageBox(strTemp); //版权 strSubBlock.Format("\\StringFileInfo\\%s\\LegalCopyright",strTranslation); VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize); strSubBlock.ReleaseBuffer(); strTemp.Format("版权: %s ",pVerValue); AfxMessageBox(strTemp); //公司名 strSubBlock.Format("\\StringFileInfo\\%s\\CompanyName",strTranslation); VerQueryValue(pBlock,strSubBlock.GetBufferSetLength(256),(LPVOID*)&pVerValue,&nSize); strSubBlock.ReleaseBuffer(); strTemp.Format("公司名: %s ",pVerValue); AfxMessageBox(strTemp); free(pBlock); |
转载请注明:exchen's blog » 获取文件版本信息