###Date: 2017/9/22
###Author : SoaringLee
Usually we can see that in Windows executable files, the right-click properties contain information such as file version, file name and version. This article describes how to add these information.
Method 1: Create a resource file in the VS project and compile it
This method is relatively simple. It is based on the VS project. The information of the file version is actually compiled through the resource file.Method 2: Add version information to dll or exe in MinGW or Cygwin environment
1. Open cmd and enter:
call "%VS120COMNTOOLS%../../VC/vcvarsall.bat" call "E:\ProfessionalSoftware\MinGW\msys\1.0\msys.bat"Start the VS2010 compilation environment and the MinGW environment, here is to use the commands windres and rc commands.
2. Create a test.c file:
#include "stdio.h"
int add(int a, int b)
{
return a + b;
}
int main(int argc, char** argv)
{
printf("********************");
}
3. Create the resource file Res.rc file:
1 VERSIONINFO
FILEVERSION 0,1,22,33
PRODUCTVERSION 1,0,0,0
FILEFLAGS 0x1L
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x1L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904E4"
BEGIN
VALUE "CompanyName", "My Company Name"
VALUE "FileDescription", "My excellent application"
VALUE "FileVersion", "6000"
VALUE "InternalName", "my_app"
VALUE "LegalCopyright", "My Name"
VALUE "OriginalFilename", "my_app.exe"
VALUE "ProductName", "My App"
VALUE "ProductVersion", "6000"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x809, 1252
END
4. Compile the link, convert the resource file rc into a res file, and then link to the dll or exe
gcc -c test.c -o test.o
windres Res.rc -O coff -o obj.res
gcc -o test test.o obj.res
or:cl -c test.c
windres Res.rc -O coff -o obj.res
link test.obj obj.res
Another method is to use the rc command to convert the res file to an rc file.cl -DWIN64 -c obj.c -Foobj
rc -DWIN64 -fo obj.res obj.rc
link obj.obj obj.res
Ok, now you can right-click Properties to view the version information of the executable file.