获取文件信息

获取文件信息

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);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值