如何得到指定文件的公司名称,文件描述,内部名称,合法版权,原始文件名,产品名称,产品版本等一系列信息?
下面这个链接有一个介绍,可那是bcb的,在vc中该如何获得?
http://www.ccrun.com/doc/go.asp?id=85
---------------------------------------------------------------
char* szFileName = "C:\\EnochShen.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为英文
//文件描述
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);
free(pBlock);
获取文件信息
最新推荐文章于 2024-09-13 21:09:25 发布