View Full Version : Adding a version resource to a plugin easily
Groucho2004
3rd September 2016, 10:04
There are many Avisynth plugins which don't have a version resource although it is much easier for the users (and developers) to keep track of and identify plugins (or any binaries for that matter) with this resource present.
I suppose in most cases the reason for omitting the version resource is that the free editions of Visual Studio don't come with a resource compiler. The Platform SDK contains a resource compiler but many just don't know it or don't want to download/install it.
There is another, very easy way to add a version resource (for 32 and 64 bit binaries):
Create a RC script and save it as 8 bit ANSI text, example below:
#define VERSION_NUM 1,0,0,0
#define VERSION_STR "1.0.0.0\0"
#define PRODUCTNAME_STR "MyPlug\0"
#define COPYRIGHT_STR "Copyright (c) 2000-2099, Me\0"
#define COMMENTS_STR "MyPlug - Avisynth Example Plugin\0"
#include <winres.h>
//#define IDI_MAINFRAME 101
//IDI_MAINFRAME ICON DISCARDABLE "MyPlug.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_NUM
PRODUCTVERSION VERSION_NUM
FILEOS VOS_NT
FILETYPE VFT_APP
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", COMMENTS_STR
VALUE "FileDescription", PRODUCTNAME_STR
VALUE "FileVersion", VERSION_STR
VALUE "LegalCopyright", COPYRIGHT_STR
VALUE "ProductName", PRODUCTNAME_STR
VALUE "ProductVersion", VERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
The values in bold are the ones you would usually modify to your needs.
Un-comment the first two lines if you want to add a custom icon to your DLL.
Download Jeremy Gordon's free resource compiler (http://www.godevtool.com/#rc). The command line for compiling your resource (can be implemented as a custom build step in your project file):
"gorc/r MyPlug.rc"
This will create a file "MyPlug.res". All you have to do is add this file to your linker input just as you would add any .obj/.lib file.
jpsdr
3rd September 2016, 11:10
Yes. After you just have to don't forget to edit and change the version when you make a new build... :p
Groucho2004
3rd September 2016, 12:10
Yes. After you just have to don't forget to edit and change the version when you make a new build... :pThat can be automated.
Wilbert
15th September 2016, 21:26
VC Express doesn't have a resource editor, but it comes with a resource compiler. It's included in the Windows SDK that comes with VC Express (so you even don't need to install Windows SDK separately).
Groucho2004
15th September 2016, 22:06
VC Express doesn't have a resource editor, but it comes with a resource compiler. It's included in the Windows SDK that comes with VC Express (so you even don't need to install Windows SDK separately).
As far as I recall, with the express versions one always had to download the (core) Platform SDK separately to get the resource compiler, other tools, additional libraries, etc.
However, last express version I used was 2005 or 2008 so things may have changed.
StainlessS
17th September 2016, 04:34
That can be automated.
“Curiouser and curiouser!” Cried Alice.
Any way that one can use a define/defines in the CPP source ?
(I just know that I would never remember to edit the resource file).
TheRyuu
17th September 2016, 06:24
As far as I recall, with the express versions one always had to download the (core) Platform SDK separately to get the resource compiler, other tools, additional libraries, etc.
However, last express version I used was 2005 or 2008 so things may have changed.
The community edition of 2015 (the free one) has very nearly feature parity with the profession version[1].
[1] https://www.visualstudio.com/products/compare-visual-studio-2015-products-vs
Groucho2004
17th September 2016, 09:41
“Any way that one can use a define/defines in the CPP source ?
(I just know that I would never remember to edit the resource file).
Here's (https://support.microsoft.com/en-gb/kb/237870) a way to do it. As for updating the version manually - I have always used a version resource (well, at least for the last ~20 years) and I usually don't forget to update it. It's just like flushing the toilet after taking a dump.
StainlessS
17th September 2016, 15:45
Cheers Grouchy, that clears up all questions.
(I'm so impressed that you remember to flush, I usually dont remember till its built up to the level that it touches my bum :) )
Groucho2004
21st April 2017, 09:34
I just found verpatch (http://ddverpatch.codeplex.com/), probably the easiest way to add a version resource.
StainlessS
22nd February 2018, 17:54
Here's (https://support.microsoft.com/en-gb/kb/237870) a way to do it. As for updating the version manually - I have always used a version resource (well, at least for the last ~20 years) and I usually don't forget to update it. It's just like flushing the toilet after taking a dump.
Above link broken.
And JFYI, the Resource compiler rc.exe is available in VS2008 Express, in the path (on 32 bit WXP):-
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
and if Platform SDK Win7 DotNet 3.5, then
C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin
EDIT: Dont know if this of use, ResEdit, seems to have been updated to v1.6.6 in 2017. http://www.resedit.net/
Also need Platform SDK.
EDIT: XN Resource Editor Unofficial mirror of version 3.0.0.1. (Official site is down) [Resource hacker only, not for developer]:-
https://stefansundin.github.io/xn_resource_editor/
Resource Hacker v4.5.30 [Resource hacker only, not for developer]:-
http://www.angusj.com/resourcehacker/#download
My original version was about v3.5, so lots of changes since then (v3.5 not even mentioned in changelog).
StainlessS
24th February 2018, 18:43
OK, here my take on adding Version Resource to a plug for VS 2008 Express, needs Platform SDK.
I tried ResEdit (linked prev post), and it produces something like this (an alternative method of specifying a version resource).
resource.h
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
test.rc (all empty settings by default)
// Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015
// http://www.resedit.net
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"
//
// Version Information resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
1 VERSIONINFO
FILEVERSION 0,0,0,0
PRODUCTVERSION 0,0,0,0
FILEOS VOS_UNKNOWN
FILETYPE VFT_UNKNOWN
FILESUBTYPE VFT2_UNKNOWN
FILEFLAGSMASK 0
FILEFLAGS 0
{
BLOCK "StringFileInfo"
{
BLOCK "08090025"
{
VALUE "Comments", ""
VALUE "CompanyName", ""
VALUE "FileDescription", ""
VALUE "FileVersion", ""
VALUE "InternalName", ""
VALUE "LegalCopyright", ""
VALUE "LegalTrademarks", ""
VALUE "OriginalFilename", ""
VALUE "PrivateBuild", ""
VALUE "ProductName", ""
VALUE "ProductVersion", ""
VALUE "SpecialBuild", ""
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0809, 0x0025
}
}
I tried this out by (Solution Explorer:right click) Resource Files/test.rc Open With, and pointed to ResEdit.
Tried edit in ResEdit, works ok, but decided to try by specifying Open With "Source Code (Text) Editor (Default)" (I set this as the Default).
and using below VersionInfo resource style. [Uses BEGIN and END instead of { and } in resource.rc].
resource.h
#ifndef IDC_STATIC
#define IDC_STATIC (-1) // ssS, This dont seem necessary, added by ResEdit. We keep it here anyway.
#endif
#include "Version.h"
Version.h [Edit this file, first few lines, in new version source]
#define Version_Major 2
#define Version_Minor 20 // Two Digits
#define Version_Beta 00 // Two Digits (00 = Not beta)
#define MyPlugName "WaterMark2\0"
#define MyVersion_Copyright "(c) 2012 Phill van leersum AKA DrPhil\0"
#define MyVersion_Implementor "(c) 2018, Steve Jones AKA StainlessS\0"
// #x Encloses the argument x in quotes.
// #@x Encloses the argument x in single quotes.
// ## Concatenates tokens used as arguments to form other tokens.
#define _STR(x) #x
#define STR(x) _STR(x)
#define MyVersion_Number Version_Major,Version_Minor,Version_Beta,0
#if(Version_Beta > 0)
#define MyVersion_String STR(Version_Major) "." STR(Version_Minor) ".Beta" STR(Version_Beta)
#else
#define MyVersion_String STR(Version_Major) "." STR(Version_Minor) "." STR(Version_Beta) "." STR(0)
#endif
// Below MUST BE set for avs v2.58 and avs+ x64, Configuration Properties/Resources/General/PreProcessor Definitions
// Avs v2.58, Add definition 'AVISYNTH_PLUGIN_25'
// Avs+ v2.60 x64, Add definition '_WIN64'
#ifdef AVISYNTH_PLUGIN_25
#define MyComments "Windows XP Rules OK\0"
#define MyOriginalDllName MyPlugName "_25.dll\0"
#define MyDescription "Avisynth v2.58 32 bit CPP Plugin\0"
#else
#ifdef _WIN64
#define MyComments "Windows XP Rules OK\0"
#define MyOriginalDllName MyPlugName "_x64.dll\0"
#define MyDescription "Avisynth+ v2.60 64 bit CPP Plugin\0"
#else
#define MyComments "Windows XP Rules OK\0"
#define MyOriginalDllName MyPlugName "_x86.dll\0"
#define MyDescription "Avisynth+ v2.60 32 bit CPP Plugin\0"
#endif
#endif
resource.rc
#include <windows.h>
#include <commctrl.h> // ssS, This dont seem necessary, added by ResEdit. We keep it here anyway.
#include <richedit.h> // ssS, This dont seem necessary, added by ResEdit. We keep it here anyway.
#include "resource.h"
//
// Version Information resources
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION MyVersion_Number
PRODUCTVERSION MyVersion_Number
FILEOS VOS_NT
FILETYPE VFT_DLL //VFT_DLL for DLL, VFT_APP for application
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", MyComments
VALUE "FileDescription", MyDescription
VALUE "FileVersion", MyVersion_String
VALUE "LegalCopyright", MyVersion_Copyright
VALUE "OriginalFilename", MyOriginalDllName
VALUE "ProductName", MyPlugName
VALUE "SpecialBuild", MyVersion_Implementor
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
As above, everything works just fine with VS 2008 Express, easy to edit in text editor, no messing with custom build or adding to linker inputs, easy peasy.
You might want to mod the bits in blue above, I'm gonna compile for avs 2.58, and avs+ x86, and avs+ x64.
And my includes in cpp file.
// ----------------------------------------------------------------
// For AVS+, also need additional Avisynth+ headers somewhere in an AVS directory,
//
// AVS
// alignment.h
// avisynth.h
// capi.h
// config.h
// cpuid.h
// minmax.h
// types.h
// win.h
//
// Point Menu/Tools/Options/Projects and Solutions/VC Directories/ :Include Files: Win32 and x64, to AVS Parent.
//
// For x64, add '_WIN64' to Preprocessor Definitions (Do NOT delete any 'WIN32' entry).
// For Avs v2.5, Add 'AVISYNTH_PLUGIN_25' to Preprocessor Definitions.
// Avs v2.5 includes AVISYNTH_INTERFACE_VERSION=3 as avisynth25.h
// Avs+ v2.6/x86/x64 includes AVISYNTH_INTERFACE_VERSION=6 as avisynth.h
// ----------------------------------------------------------------
#include "Compiler.h"
#include <windows.h>
#include <stdio.h>
#include "Version.h"
#ifdef AVISYNTH_PLUGIN_25
#include "Avisynth25.h"
#else
#include "Avisynth.h"
#endif
And for Plugin Registration in cpp file.
#ifdef AVISYNTH_PLUGIN_25
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
#else
const AVS_Linkage *AVS_linkage = 0;
extern "C" __declspec(dllexport) const char* __stdcall
AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
AVS_linkage = vectors;
#endif
env->AddFunction("Watermark2", "c[watermark]c[displace]i[light]i[depth]i[softEdge]b[lightFrom]s",Watermark2::Create,0);
return "`Watermark2 plugin' Watermark2 plugin";
// A freeform name of the plugin.
}
See Next post for Configuration Properties/Resources/General/PreProcessor Definitions
(Add '_WIN64' for 64 bit, and 'AVISYNTH_PLUGIN_25' for avs v2.58)
EDITED:
StainlessS
25th February 2018, 06:51
Below Assumes that VS C++ 2008 Express, is set up with a Platform SDK and can compile to x64 64 bit.
To create Avisynth dll projects, for Avisynth 2.58 and Avisynth+ 2.6 x86 and x64 in one solution in the
least insane way(that I have found), using Visual Studio 2008 Express Edition.
We also here use settings to include VersionInfo in dll's as outlined in previous posts.
Express edition does not support creation of a empty Solution, and without one, you can end up being
forced to have Debug and Release projects for avs+ x86/x64, and avs v2.58 x86/x64, ie dont seem to be able to
create only x86 project (without x64) for the avisynth v2.58 project.
(you can delete avs v2.58 x64, but it just comes back again). We need a means to create an Empty Solution.
[If anybody knows of a more sane solution, we would all like to know about it].
Creating an Empty Solution in VC++ 2008 Express (No option for this in Express edition).
From Visual Studio C++ Express,
Select: File/New Project/Win32/ "Win32 Console Application".
Name=EmptyProject
Solution Name=EmptySolution
Tick "Create Directory for Solution".
Application Settings:-
DLL=Ticked
Empty Project=Ticked.
Click "Finsh".
In Solution Explorer Window:
Right Click Unload Project
Right Click "Empty Project(unavailable)", Select "Remove".
Press CTRL/S to save Empty Solution.
Exit, and navigate to "My Documents\Visual Studio 2008\Projects\Empty Solution\" directory.
Delete "EmptyProject" directory.
Delete "EmptySolution.ncb" (Intellisense file).
Delete "EmptySolution.suo" (Solution User Options file).
You now have "EmptySolution\EmptySolution.sln", ie an empty solution.
Add a "Src" Directory inside EmptySolution\, and make a copy of your EmptySolution Directory somewhere.
To create Avisynth dll projects, for Avisynth 2.58 and Avisynth+ 2.6 x86 and x64 in one solution
Copy your "EmptySolution" directory together with contained Src dir and EmptySolution.sln file to destination.
Rename EmptySolution\EmptySolution.sln to EmptySolution\WaterMark2.sln (assuming that WaterMark2 is your plugin name).
Rename EmptySolution\ directory to eg WaterMark2 (or whatever your plugin will be called).
You now have WaterMark2\WaterMark2.sln (directory and empty solution file) and WaterMark2\Src directory.
To create an avs+ x86 Project that will also become x64 project:-
From Visual Studio C++ Express,
Select: File/New Project/Win32/ "Win32 Console Application".
Name=WaterMark2 (Same as above renamed solution)
UNTICK "Create Directory for Solution".
Application Settings:-
DLL=Ticked
Empty Project=Ticked.
Click "Finish".
To Create avs v2.58 Project that will NOT house an additional x64 project:-
From Visual Studio C++ Express,
Select: File/New Project/Win32/ "Win32 Console Application".
Name=WaterMark2_25 (Same as above renamed solution but additional '_25' after it)
UNTICK "Create Directory for Solution".
Application Settings:-
DLL=Ticked
Empty Project=Ticked.
Click "Finish".
You now can copy WaterMark2 (x86 + x64) project and WaterMark2_25 (avs v2.58) project into the WaterMark2 Empty Solution.
Configure Avs+ x86 Project.
Enter WaterMark2/WaterMark2/ and click on WaterMark2.vcproj, and navigate upwards to enter Header files,
Resource files, and cpp source files, from the WaterMark2\Src directory, or create them there.
Select ONLY Avisynth.h for the Avs+ project, not Avisynth25.h.
Do all settings for avs+ x86 Debug and Release.
Debug Configuration Properties:-
General
Enable Managed Incremental build = No
C++
General
Debug Information Format = Program Database(/Zi)
Optimization
Optimization = Disabled(/Od)
Code Generation
Enable Minimal Rebuild = No(/Gm)
Runtime Library = Multi-Threaded Debug(/MTd) or Multi-Threaded Debug DLL(/MDd)
Linker
General
Output File = $(OutDir)\$(ProjectName)_x86.dll [Insert the '_x86' bit)
Enable Incremental Linking = No(/INCREMENTAL:NO)
###
Release Configuration Properties:-
General
Enable Managed Incremental build = No
C++
General
Debug Information Format = Program Database(/Zi)
Optimization
Optimization = Maximize Speed(/O2)
Inline Function expansion = Any Suitable(/Ob2)
Enable Intrinsic Functions = Yes(/Oi)
Favor Size or Speed = Favor Fast Code(/Ot)
Code Generation
Runtime Library = Multi-Threaded(/MT) or Multi-Threaded DLL(/MD)
Enable Function Level Linking = No
Linker
General
Output File = $(OutDir)\$(ProjectName)_x86.dll [Insert the '_x86' bit)
Enable Incremental Linking = No(/INCREMENTAL:NO)
Generate Debug Info = No
CTRL/S, Save configuration.
Make Avs+ x64 Project.
Menu/Build/Configuration Manager/
Active Solution Configuration = Debug
Active Solution Platform = New : Type or select new platform = x64
Select 'Copy Settings From / Win32', Tick 'Create New project platforms', and OK.
Configure settings for avs+ x64 Debug and Release.
WaterMark2:Debug x64 Configuration Properties:-
C++
PreProcessor
PreProcessor Definitions Add '_WIN64' separating from existing defs with a semicolon(;)[do not del 'WIN32'].
Linker
General
Output File = $(OutDir)\$(ProjectName)_x64.dll [Insert the '_x64' bit)
Resources
General
PreProcessor Definitions # Add '_WIN64' separating from existing defs with a semicolon(;).
CTRL/S, Save configuration.
###
WaterMark2:Release x64 Configuration Properties:-
C++
PreProcessor
PreProcessor Definitions Add '_WIN64' separating from existing defs with a semicolon(;)[do not del 'WIN32'].
Linker
General
Output File = $(OutDir)\$(ProjectName)_x64.dll [Insert the '_x64' bit)
Resources
General
PreProcessor Definitions # Add '_WIN64' separating from existing defs with a semicolon(;).
CTRL/S, Save configuration.
Test both avs+ x86 and x64.
Menu/build/Batch Build/
Tick all 4 options, and Rebuild
Configure Avs v2.58 Project
Enter WaterMark2/WaterMark2_25/ and click on WaterMark2_25.vcproj, and navigate upwards to enter Header files,
Resource files, and cpp source files, from the WaterMark2\Src directory, or create them there.
Select ONLY Avisynth25.h for the Avs v2.58 project, not Avisynth.h.
Do all settings for avs v2.58 Debug and Release, same as you did for WaterMark2 project (avs+ x86).
Additional settings for WaterMark2_25 (Avisynth v2.58 project):-
WaterMark2_25:Debug Configuration Properties:-
C++
PreProcessor
PreProcessor Definitions Add 'AVISYNTH_PLUGIN_25' separating from existing defs with a semicolon(;).
Linker
General
Output File = $(OutDir)\$(ProjectName).dll [DO NOT Insert '_25' [will already append '_25])
Resources
General
PreProcessor Definitions # Add 'AVISYNTH_PLUGIN_25' separating from existing defs with a semicolon(;).
CTRL/S, Save configuration.
WaterMark2_25:Release Configuration Properties:-
Repeat as for above additional WaterMark2_25:Debug Configuration Properties:-
CTRL/S, Save configuration.
Test both avs v2.58 Debug and Release (no x64).
Menu/build/Batch Build/
Tick both options, and Rebuild
Adding Avs v2.58 and Avs+ v2.60 x86 and x64 Projects to our Empty waterMark2 Solution.
Double click WaterMark2\WaterMark2.sln.
In Solution Explorer, Right Click:Solution '(0 projects):Add:Existing Project.../ WaterMark2\WaterMark2.vcproj
In Solution Explorer, Right Click:Solution '(1 projects):Add:Existing Project.../ WaterMark2\WaterMark2_25.vcproj
CTRL/S, Save Solution.
Test All 6 solution outputs,
Double click WaterMark2\WaterMark2.sln.
Menu/build/Batch Build/
Tick all 6 options, and Rebuild
Nearly Last Step,
Delete all Debug and Release directories anywhere within WaterMark2 Solution directory, and also any x64 directories.
Last Step, Repeat test All 6 solution outputs
Double click WaterMark2\WaterMark2.sln.
Menu/build/Batch Build/
Tick all 6 options, and Rebuild
Dll Creation output directories.
WaterMark2\Debug\
WaterMark2_x86.dll
WaterMark_25.dll
WaterMark2\Release\
WaterMark2_x86.dll
WaterMark_25.dll
WaterMark2\x64\Debug\
WaterMark2_x64.dll
WaterMark2\x64\Release\
WaterMark2_x64.dll
If posting zip with source and project files, can remove all *.ncb files (Intellisense),
eg WaterMark_25.ncb, and settings *.user files, eg WaterMark_25.vcproj.COMPUTERNAME.USERNAME.user,
as these will be re-created on re-compile. Can also Delete all Debug and Release Directories and
enclosed files (assuming required dll's are copied to some other directory).
If anyone has a better way, do tell.
Thanx G2K4, never would have gotten around to this without this thread. :thanks:
https://s20.postimg.cc/bh62445h9/Version_Info.jpg (https://postimages.cc/)
EDIT: Previous post EDITED.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.