Adding version info to execute file
来源:互联网 发布:增强信号的软件 编辑:程序博客网 时间:2024/06/11 15:59
#include "stdafx.h"
struct VS_VERSIONINFO
{
WORD wLength;
WORD wValueLength;
WORD wType;
WCHAR szKey[1];
WORD wPadding1[1];
VS_FIXEDFILEINFO Value;
WORD wPadding2[1];
WORD wChildren[1];
};
struct
{
WORD wLanguage;
WORD wCodePage;
} *lpTranslate;
void main( void )
{
VS_VERSIONINFO *pVerInfo;
LPBYTE pOffsetBytes;
VS_FIXEDFILEINFO *pFixedInfo;
LPCTSTR lpszOrigFile = _T("c://Notepad.exe");
LPCTSTR lpszFile = _T("c://proxy.exe");
DWORD dwHandle,
dwSize,
dwResult = 0;
// determine the size of the resource information
dwSize = GetFileVersionInfoSize(lpszOrigFile, &dwHandle);
if (0 < dwSize)
{
LPBYTE lpBuffer = new BYTE[dwSize];
if (GetFileVersionInfo(lpszOrigFile, 0, dwSize, lpBuffer) != FALSE)
{
// these macros help to align on r-byte boundaries (thanks Ted Peck)
#define roundoffs(a,b,r) (((BYTE *) (b) - (BYTE *) (a) + ((r) - 1)) & ~((r) - 1))
#define roundpos(a,b,r) (((BYTE *) (a)) + roundoffs(a,b,r))
// 'point to' the start of the version information block
pVerInfo = (VS_VERSIONINFO *) lpBuffer;
// the fixed section starts right after the 'VS_VERSION_INFO' string
pOffsetBytes = (BYTE *) &pVerInfo->szKey[_tcslen(pVerInfo->szKey) + 1];
pFixedInfo = (VS_FIXEDFILEINFO *) roundpos(pVerInfo, pOffsetBytes, 4);
// increment the numbers!
pFixedInfo->dwFileVersionMS = pFixedInfo->dwFileVersionMS + 0x00010001;
pFixedInfo->dwFileVersionLS = pFixedInfo->dwFileVersionLS + 0x00010001;
pFixedInfo->dwProductVersionMS = pFixedInfo->dwProductVersionMS + 0x00010001;
pFixedInfo->dwProductVersionLS = pFixedInfo->dwProductVersionLS + 0x00010001;
HANDLE hResource = BeginUpdateResource(lpszFile, FALSE);
if (NULL != hResource)
{
UINT uTemp;
// get the language information
if (VerQueryValue(lpBuffer, _T("//VarFileInfo//Translation"), (LPVOID *) &lpTranslate, &uTemp) != FALSE)
{
// could probably just use LANG_NEUTRAL/SUBLANG_NEUTRAL
if (UpdateResource(hResource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO), lpTranslate->wLanguage, lpBuffer, dwSize) != FALSE)
{
if (EndUpdateResource(hResource, FALSE) == FALSE)
dwResult = GetLastError();
}
else
dwResult = GetLastError();
}
}
else
dwResult = GetLastError();
}
else
dwResult = GetLastError();
delete [] lpBuffer;
}
else
dwResult = GetLastError();
if (0 != dwResult)
wprintf(_T("Operation was not successful. Result = %lu/n"), dwResult);
}
- Adding version info to execute file
- How to execute jar file
- Mantis SVN Integration : Adding extra info to the Note
- Adding SVN Information to File Headers Revisited
- GDB : save debug info to a file
- CFBundleVersion in Info.plist file must contain a higher version
- T_SQL : to execute local .sql file
- Failed to execute mysql_file_stat on file
- Why is SPD adding content to my file?
- Linux: Check version info
- CFBundleVersion in the Info.plist file must contain a higher version than that of the previously uploaded version.
- MySQL server version for the right syntax to use near 'info where info.stu_id = 1' at line 1
- Adding checkbox to mshflexgrid
- Adding assembly to GAC
- Adding a File to a Run-time Image (Windows CE 5.0)
- UNNAMED FILE ERROR IN STANDBY AFTER ADDING NEW FILE TO PRIMARY DATABASE – ORA-01111, ORA-01110, ORA-
- Failed to detect version of solution/project file
- Windows File Info
- 遭遇网页挂马(第五) ―― 基于不信任的请求验证
- 超市将成为淘宝的仓库中心
- c# WebBrowser开发参考资料
- protel dxp 2004的破解
- BlazeDS是什么?
- Adding version info to execute file
- 重获新生 之 E公司报到——《轻松Scrum之旅》(6)
- B2C大点名:国内B2C网站收集(更新至2009年6月2日)
- CSS_解决IE6中min-width问题
- 版本1.0字典类型
- JAVA 类包 搜索引擎 - http://www.jar114.com/
- MFC常用方法
- 推荐八个配色网站
- CSS_解决IE6中min-width问题