#### Archived

This topic is now archived and is closed to further replies.

# Keeping track of build numbers in VC6??

This topic is 5843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do you keep track of build numbers in VC6? Is it possible to have the studio keep track of it and update a string every time you build it, or is that left to the developer? I''m just wondering there is an easier way to do this rather than by hand, because it is helpful for beta testing and I am to forgetful to update a variable every time I build. "Victims...aren''t we all?" -Brandon Lee, the Crow

##### Share on other sites
There''s an MSVC VBScript hack to do this, as well as macros. Check out Code Guru and The Code Project for variations.

I wanna work for Microsoft!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

##### Share on other sites
Once again, thanks to everyone on Gamedev.net forums for the help. I don''t know of any other board that gets me the answers I''m looking for, let alone so quickly. Thanks Oluseyi.

"Victims...aren''t we all?"
-Brandon Lee, the Crow

##### Share on other sites
Once again, thanks to everyone on Gamedev.net forums for the help. I don''t know of any other board that gets me the answers I''m looking for, let alone so quickly. Thanks Oluseyi.

"Victims...aren''t we all?"
-Brandon Lee, the Crow

##### Share on other sites
There was also a script as a Code of the Day or Tip of the Day on flipcode.

##### Share on other sites

Hah, if I use such a tool to automatically increment a
counter whenever I build the EXE, I doubt that even
an unsigned long int (2^32-1) can hold it.

Just kidding!

But, seriously, I bet it''d read at least 50,000 when I''m
"done" with the first version.

Premature optimizations can only slow down your project even more.

##### Share on other sites
I wrote a function to do this. Maybe not the best way, but it works well. The function gets called each time the program is run, and it uses a short file (12 bytes long, actually) to tell whether the build number needs to get incremented, and also what the build number is. For a release build, you'd disable this and enter the number yourself.

This is the function (Build is an integer declared elsewhere, and this code assumes Debug\ is your build directory):

  void UpdateBuildNumber ( ){ FILETIME LogTime; FILETIME ObjTime; HANDLE ObjFile; FILE* BuildLog; BuildLog = fopen( "Build.bin", "rb" ); if( !BuildLog ) { Build = 1; LogTime.dwLowDateTime = 0; LogTime.dwHighDateTime = 0; BuildLog = fopen( "Build.bin", "wb" ); fwrite( &Build, 4, 1, BuildLog ); fwrite( &LogTime, 8, 1, BuildLog ); fclose( BuildLog ); return; } fread( &Build, 4, 1, BuildLog ); fread( &LogTime, 8, 1, BuildLog ); fclose( BuildLog ); ObjFile = CreateFile( "Debug\\vc60.pdb", // vc50.pdb if using VC++ 5.0 GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); if( !ObjFile ) return; GetFileTime( ObjFile, NULL, NULL, &ObjTime ); CloseHandle( ObjFile ); if( CompareFileTime( &LogTime, &ObjTime ) < 0 ) { Build ++; BuildLog = fopen( "Build.bin", "wb" ); fwrite( &Build, 4, 1, BuildLog ); fwrite( &ObjTime, 8, 1, BuildLog ); fclose( BuildLog ); } BuildLog = fopen( "Version.txt", "wb" ); // Write the build number to a text fprintf( BuildLog, "Build #%ld\r\n", Build ); // file so you can see it. fclose( BuildLog );}

 Changed the filename from "Build.txt" to "Build.bin" since it's not a text file. [/edit]

[edit #2] Although I haven't tested this aspect of it, probably if you do an unsuccessful compile, and then run the executable from the last successful build (by pressing Ctrl+F5 and clicking "No" when it asks if you want to compile), the build counter will get incremented when it shouldn't. This isn't anything major but it's definitely something to be aware of, and a drawback of the method I use. [/edit #2]

~CGameProgrammer( );

Edited by - CGameProgrammer on February 19, 2002 1:54:29 PM

##### Share on other sites
Why don''t you just use the current date and time? It automatically updates for you and shows others you code until 4am