Crappy little tool I made

edited for drunken style code fu.

I searched for this type of functionality and ended up doing my own.

I’m creating a tool for my boss and sending him updates regularly. I got pissed off manually naming filenames with version info. and indeed maintaining a version number in the code (for title bar etc)


int _tmain(int argc, _TCHAR* argv[])

	int majorInc = 0, minorInc = 0, buildInc = 0, major = 0, minor = 0, build = 0;
	String file, fs;

	StringArray cmdl( (const juce_wchar**) argv, argc );

	for ( int i = 0; i < cmdl.size(); ++i )
		if ( cmdl[ i ].contains( T("maj") ) )
			majorInc = cmdl[ i ].getTrailingIntValue();
		else if ( cmdl[ i ].contains( T("min") ) )
			minorInc = cmdl[ i ].getTrailingIntValue();
		else if ( cmdl[ i ].contains( T("bld") ) )
			buildInc = cmdl[ i ].getTrailingIntValue();
		else if ( cmdl[ i ].contains( T("file=") ) )
			file = cmdl[ i ].substring( cmdl[ i ].lastIndexOf( T("=") ) + 1 );

	File f( File::getCurrentApplicationFile().getParentDirectory().getFullPathName() + T("\\vinfo.txt") );	

	if ( f.existsAsFile() )
		fs = f.loadFileAsString();
		StringArray sa;
		sa.addLines( fs );

		major = sa[ 0 ].getTrailingIntValue();
		minor = sa[ 1 ].getTrailingIntValue();
		build = sa[ 2 ].getTrailingIntValue();

	major += majorInc;
	minor += minorInc;
	build += buildInc;

	fs = T("#define MAJORV ") 
		+ String( major ) 
		+ T("\n#define MINORV ") 
		+ String( minor ) 
		+ T("\n#define BUILDN ") 
		+ String( build ) 
		+ T("\n");


	f.appendText( fs );

	File exe( file );
	if ( exe.existsAsFile() )
		exe.copyFileTo( File( exe.getParentDirectory().getFullPathName() + T("\\") 
			+ exe.getFileNameWithoutExtension() 
			+ String( major ) + T("_") 
			+ String( minor ) + T("_") 
			+ String( build )
			+ exe.getFileExtension() ) );
	return 0;

I compiled this as versionburster.exe and put it in my project directory.

so in my release pre build event I have

debug pre build event I have

at the top of main.cpp

which gives me macros for MAJORV MINORV and BUILDN to use in a title bar or wherever.

then in the post-build events I have

which simply copies the output file to filenameMAJORV_MINORV_BUILDN.exe

works for me. took half an hour. might be of use to someone.

happy new year



Since it is a windows application, I also put my version info in the resource file (you know, right click the file, properties, version). Easy access and can be set easily from source.

I’ve never had anything to do with resource files. don’t like the look of them. a bit shifty.

not sure what our getting at to be honest! could you explain further?


Windows resource files can be wonderful, you can even have your app pick and choose from different libraries (like versions) to load depending on the operating system version and such as well, I use that often enough.