Windows(CodeBlocks) 純 C/C++ 在專案中 增加 版本資訊 和 顯示 版本資訊
資料來源:http://www.tk4479.net/bowa21c/article/details/17203339
https://msdn.microsoft.com/zh-tw/library/windows/desktop/aa381058(v=vs.85).aspx
GITHUB: https://github.com/jash-git/CB_Set_Get_Version.git
main.cpp
#include <iostream>
#include <cstdio>
#include “version.h”
using namespace std;
void Pause()
{
printf(“Press Enter key to continue…”);
fgetc(stdin);
}
int main()
{
cout << “Hello world!” << endl;
cout << “ProductVersion” << RC_FILEVERSION_STRING<< endl;
Pause();
return 0;
}
|
version.h
#ifndef VERSION_H
#define VERSION_H
namespace AutoVersion{
//Date Version Types
static const char DATE[] = “08”;
static const char MONTH[] = “12”;
static const char YEAR[] = “2013”;
static const char UBUNTU_VERSION_STYLE[] = “13.12”;
//Software Status
static const char STATUS[] = “Alpha”;
static const char STATUS_SHORT[] = “a”;
//Standard Version Type
static const long MAJOR = 0;
static const long MINOR = 0;
static const long BUILD = 0;
static const long REVISION = 0;
//Miscellaneous Version Types
static const long BUILDS_COUNT = 11;
#define RC_FILEVERSION 0,1,0,7 //要刪除bin和obj兩個目錄
#define RC_FILEVERSION_STRING “0, 1, 0, 7\0” //要刪除bin和obj兩個目錄
static const char FULLVERSION_STRING [] = “0.0.0.0”;
//These values are to keep track of your versioning state, don’t modify them.
static const long BUILD_HISTORY = 7;
}
#endif //VERSION_H
|
resource.rc
#include “version.h”
1 VERSIONINFO
FILEVERSION RC_FILEVERSION
PRODUCTVERSION 1,0,0,0
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK “StringFileInfo”
BEGIN
BLOCK “040904b0”
BEGIN
VALUE “FileVersion”, RC_FILEVERSION_STRING
VALUE “ProductName”, “C_Set_Get_Version\0”
VALUE “ProductVersion”, RC_FILEVERSION_STRING
VALUE “CompanyName”, “Jash’s Studio\n”
VALUE “LegalCopyright”, “(C)Jash’s Studio, 2013\n”
END
END
BLOCK “VarFileInfo”
BEGIN
VALUE “Translation”, 0x0409, 0x0000 //0x0804, 0x0000
END
END
|