Autoincreasing build number

Here is a macro that auto-increments the version information  of your VC++ projects with every new build. The behaviour is quite similar to the version autoincrement in VisualBasic or Delphi.

The Macro searches for the FileVersion section of your projects resource script. The last number of this quadrupel is automacilly increased and written back to the file. At last the project is build as by pressing F7.

As this macro includes full functionality of F7 you can map it to F7 to include the version auto-increment in your build routine.

To access this Version info from within your application use the CVersionInfo class by Roberto Rocco presented elsewhere on www.codeguru.com


Sub IncResVersion()
	'DESCRIPTION: Build active project and increase version counter in rc script. Map it to F7 for ease of use. (c)'98 Th. Mahler

	' open the project's resource script:
	Documents.Open (ActiveProject.Name + ".rc"), "Text"
	Windows(ActiveProject.Name + ".rc").Active = True
	' find line with FileVersion Information:
	ActiveDocument.Selection.FindText "VALUE ""FileVersion"",", dsMatchForward + dsMatchFromStart + dsMatchCase  

	' move to eol and then to end of build number:
	ActiveDocument.Selection.EndOfLine
	ActiveDocument.Selection.CharLeft dsMove, 3 

	' mark Build Number and store in strVersion
	ActiveDocument.Selection.WordLeft 1  'dsExtend does not work in my VisualStudio???
	Dim strVersion
	strVersion = ActiveDocument.Selection.Text 

	' Increase Version and write back to file: 
	ActiveDocument.Selection.ReplaceText strVersion , strVersion+1 

	'close RC file
	ActiveDocument.Close() 

	'build active project
	ExecuteCommand "BuildToggleBuild"
	Documents.SaveAll True  

End Sub 


Comments

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

  • With 81% of employees using their phones at work, companies have stopped asking: "Is corporate data leaking from personal devices?" and started asking: "How do we effectively prevent corporate data from leaking from personal devices?" The answer has not been simple. ZixOne raises the bar on BYOD security by not allowing email data to reside on the device. In addition, Zix allows employees to maintain complete control of their personal device, therefore satisfying privacy demands of valued employees and the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds