Keeping track of build numbers in VC6??

Started by
6 comments, last by KaneBlackflame 22 years, 1 month ago
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
"Victims...aren't we all?" -Brandon Lee, the Crow
Advertisement
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!
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
"Victims...aren't we all?" -Brandon Lee, the Crow
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
"Victims...aren't we all?" -Brandon Lee, the Crow
There was also a script as a Code of the Day or Tip of the Day on flipcode.

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.
神はサイコロを振らない!
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 );}        


[edit] 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

~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
Why don''t you just use the current date and time? It automatically updates for you and shows others you code until 4am

This topic is closed to new replies.

Advertisement