GetFileVersionInfo
来源:互联网 发布:淘宝卖家怎么清洗订单 编辑:程序博客网 时间:2024/06/07 22:06
#include <stdio.h>#include <windows.h>#include <assert.h>#include <tchar.h>#pragma comment(lib,"Version.lib")wchar_t* QueryValue(wchar_t* pValueName , wchar_t* pModuleName) { PBYTE lpVersionData = NULL; DWORD dwLangCharset = 0; UINTnQuerySize; DWORD* pTransTable; wchar_t szText[MAX_PATH]={0};wchar_t* lpData=NULL; DWORD dwHandle; DWORD dwDataSize; do { dwDataSize = GetFileVersionInfoSize(pModuleName, &dwHandle); if (dwDataSize == 0) break; lpVersionData = new BYTE[dwDataSize];if ( NULL == lpVersionData) break; ZeroMemory(lpVersionData,dwDataSize);if (!GetFileVersionInfo(pModuleName, dwHandle, dwDataSize, (void*)lpVersionData)) break; // 设置语言 if (!VerQueryValue(lpVersionData, L"\\VarFileInfo\\Translation", (void **)&pTransTable, &nQuerySize)) break; dwLangCharset = MAKELONG(HIWORD(pTransTable[0]), LOWORD(pTransTable[0])); if (lpVersionData == NULL) break; LPVOID lplpBuffer;_sntprintf_s(szText, sizeof(szText),L"\\StringFileInfo\\%08lx\\%s",dwLangCharset, pValueName); if (VerQueryValue((void *)lpVersionData, szText, (LPVOID*)&lplpBuffer, &nQuerySize)){int nlen=wcslen((wchar_t*)lplpBuffer);lpData=new wchar_t[nlen+sizeof(wchar_t)];RtlZeroMemory(lpData,nlen*sizeof(wchar_t)+sizeof(wchar_t));CopyMemory(lpData,lplpBuffer,nlen*sizeof(wchar_t));}} while (FALSE); if (lpVersionData){delete[] lpVersionData;}return lpData; } int main(void){wprintf(TEXT("Comments=%s\n"),QueryValue(TEXT("Comments"),TEXT("c:\\windows\\notepad.exe")));wprintf(TEXT("CompanyName=%s\n"),QueryValue(TEXT("CompanyName"),TEXT("c:\\windows\\notepad.exe")));wprintf(TEXT("FileDescription=%s\n"),QueryValue(TEXT("FileDescription"),TEXT("c:\\windows\\notepad.exe")));wprintf(TEXT("FileVersion=%s\n"),QueryValue(TEXT("FileVersion"),TEXT("c:\\windows\\notepad.exe")));wprintf(TEXT("InternalName=%s\n"),QueryValue(TEXT("InternalName"),TEXT("c:\\windows\\notepad.exe")));wprintf(TEXT("LegalCopyright=%s\n"),QueryValue(TEXT("LegalCopyright"),TEXT("c:\\windows\\notepad.exe")));wprintf(TEXT("OriginalFilename=%s\n"),QueryValue(TEXT("OriginalFilename"),TEXT("c:\\windows\\notepad.exe")));wprintf(TEXT("ProductName=%s\n"),QueryValue(TEXT("ProductName"),TEXT("c:\\windows\\notepad.exe")));wprintf(TEXT("ProductVersion=%s\n"),QueryValue(TEXT("ProductVersion"),TEXT("c:\\windows\\notepad.exe")));wprintf(TEXT("PrivateBuild=%s\n"),QueryValue(TEXT("PrivateBuild"),TEXT("c:\\windows\\notepad.exe")));wprintf(TEXT("SpecialBuild =%s\n"),QueryValue(TEXT("SpecialBuild"),TEXT("c:\\windows\\notepad.exe")));getchar();getchar();return 0;}/*Comments=(null)CompanyName=Microsoft CorporationFileDescription=NotepadFileVersion=10.0.15063.0 (WinBuild.160101.0800)InternalName=NotepadLegalCopyright=?Microsoft Corporation. All rights reserved.OriginalFilename=NOTEPAD.EXE.MUIProductName=Microsoft?Windows?Operating SystemProductVersion=10.0.15063.0PrivateBuild=(null)SpecialBuild =(null)*/
阅读全文
0 0
- GetFileVersionInfo
- 获取EXE版本信息 GetFileVersionInfo
- WindowsAPI之GetFileVersionInfo函数和VerQueryValue函数
- 通过 GetFileVersionInfo 获取EXE 或 DLL的各种资源
- 《Windows API巡礼》---GetFileVersionInfo函数和VerQueryValue函数
- 利用WinAPI(GetFileVersionInfo)获取文件版本信息
- 如何使用API函数GetFileVersionInfo,获得版本信息
- 【转】取文件属性:GetFileVersionInfoSize,GetFileVersionInfo,VerQueryValue三个函数的配合
- 如何使用API函数GetFileVersionInfo,获得版本信息
- 通过 GetFileVersionInfo 获取EXE 或 DLL的各种资源 .
- GetFileVersionInfo 获取文件版本信息错误原因分析
- 利用WinAPI(GetFileVersionInfo)获取文件版本信息
- 这几张刷爆科技网站的机器人图(就比如这篇文章的题图),到底是从哪来的?
- 欢迎使用CSDN-markdown编辑器
- HBase中的HMaster、HRegionServer、Zookeeper
- Kafka常用操作命令及生产者与消费者的代码实现
- ActiveMq的基本使用
- GetFileVersionInfo
- 媒体调查:“晚上九点以后,就是百度灰色收入的黄金时间”
- 腾讯发布6月“星APP榜”:游戏娱乐APP揭幕暑期档
- IT桔子沙龙第71期:2016年智能硬件创投趋势探讨(上海场)
- 判断条件相结合
- 常用的搜索引擎技巧
- PAT甲级1119,1086,1020总结
- 游戏
- java中常见异常