posts - 126,  comments - 73,  trackbacks - 0
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);


from:http://www.xiaozhou.net/cooldog/article.asp?id=55
posted on 2007-01-23 11:20 我风 阅读(373) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2007年1月>
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用链接

留言簿(12)

随笔分类

随笔档案

文章档案

相册

收藏夹

C++

MyFavorite

搜索

  •  

积分与排名

  • 积分 - 319885
  • 排名 - 74

最新评论

阅读排行榜

评论排行榜