Board index » cppbuilder » Read application version in code
TerryC
![]() CBuilder Developer |
TerryC
![]() CBuilder Developer |
Read application version in code2004-08-11 11:05:04 PM cppbuilder29 Is there a way to access the version number I have given my app in the Project Options ->Version Info page? What I'd like to do is have the app automatically change the version number on my "About" form so I don't have to remember to do it manually. Thanks much, -Terry |
Andrue Cope [TeamB]
![]() CBuilder Developer |
2004-08-11 11:22:09 PM
Re:Read application version in code
TerryC wrote:
QuoteIs there a way to access the version number I have given my app DWORD versionInfoSize=GetFileVersionInfoSize( Application->ExeName.c_str(), &dumbo ); if( versionInfoSize ) { BYTE *versionInfo=new BYTE[ versionInfoSize ]; if( GetFileVersionInfo( Application->ExeName.c_str(), dumbo, versionInfoSize, versionInfo ) ) { AnsiString tmpLabelString=""; char *versionInfoBuf=NULL; unsigned int versionInfoLen=0; // NB : 080904E4 is language specific. First four digits // taken from Options/Version. // First lets build the file information if( VerQueryValue( versionInfo, "\\StringFileInfo\\080904E4\\FileDescription", &( ( void* )versionInfoBuf ), &versionInfoLen ) ) { char *fileDescStr=new char[ versionInfoLen+1 ]; strncpy( fileDescStr, versionInfoBuf, versionInfoLen ); *( fileDescStr+versionInfoLen )='\0'; if( VerQueryValue( versionInfo, "\\StringFileInfo\\080904E4\\FileVersion", &( ( void* )versionInfoBuf ), &versionInfoLen ) ) { char *fileVerStr=new char[ versionInfoLen+1 ]; strncpy( fileVerStr, versionInfoBuf, versionInfoLen ); *( fileVerStr+versionInfoLen )='\0'; { // <property>+= doesn't work :( tmpLabelString=fileDescStr; tmpLabelString+=" v"; tmpLabelString+=fileVerStr; FormAboutBox_VersionString=fileVerStr; } KillAry( fileVerStr ); } KillAry( fileDescStr ); } // Grab the copyright information char * copyrightStr=NULL; if( VerQueryValue( versionInfo, "\\StringFileInfo\\080904E4\\LegalCopyright", &( ( void* )versionInfoBuf ), &versionInfoLen ) ) { copyrightStr=new char[ versionInfoLen+1 ]; strncpy( copyrightStr, versionInfoBuf, versionInfoLen ); *( copyrightStr+versionInfoLen )='\0'; { // <property>+= doesn't work :( VersionLabel->Caption=tmpLabelString+" "+copyrightStr; } } // Now lets build the product information if( VerQueryValue( versionInfo, "\\StringFileInfo\\080904E4\\ProductName", &( ( void* )versionInfoBuf ), &versionInfoLen ) ) { char *prodDescStr=new char[ versionInfoLen+1 ]; strncpy( prodDescStr, versionInfoBuf, versionInfoLen ); *( prodDescStr+versionInfoLen )='\0'; if( VerQueryValue( versionInfo, "\\StringFileInfo\\080904E4\\ProductVersion", &( ( void* )versionInfoBuf ), &versionInfoLen ) ) { char *prodVerStr=new char[ versionInfoLen+1 ]; strncpy( prodVerStr, versionInfoBuf, versionInfoLen ); *( prodVerStr+versionInfoLen )='\0'; { // <property>+= doesn't work :( tmpLabelString=prodDescStr; tmpLabelString+=" v"; tmpLabelString+=prodVerStr; VFSVersionLabel->Caption=tmpLabelString; } KillAry(prodVerStr); } KillAry(prodDescStr); } VFSCopyrightLabel->Caption=copyrightStr; KillAry(copyrightStr); } KillAry( versionInfo ); } KillAry() is a template that calls delete[] QuoteWhat I'd like to but I can't find it. -- Andrue Cope [TeamB] [Bicester, Uk] info.borland.com/newsgroups/guide.html |
TerryC
![]() CBuilder Developer |
2004-08-12 03:13:41 AM
Re:Read application version in code
"Andrue Cope [TeamB]" < XXXX@XXXXX.COM >wrote:
[...] QuoteThis is what we use: doing, and it works perfectly. QuoteHmmm. BCB5 and later are supposed to increment the build form when I change things in Options->Version Info. Great stuff! -Terry {smallsort} |
Andrue Cope [TeamB]
![]() CBuilder Developer |
2004-08-12 04:07:20 PM
Re:Read application version in code
TerryC wrote:
QuoteMany thanks! I massaged the code you posted to fit what I'm Andrue Cope [TeamB] [Bicester, Uk] info.borland.com/newsgroups/guide.html |
SHADOW-XIII
![]() CBuilder Developer |
2004-08-12 07:28:13 PM
Re:Read application version in codeQuoteHmmm. BCB5 and later are supposed to increment the build number for you |