freebasic.net Forum Index
FreeBASIC's Official Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in

Define EXE Version

 
Post new topic   Reply to topic    freebasic.net Forum Index -> Windows
View previous topic :: View next topic  
Author Message
Coviti

PostPosted: Oct 04, 2006 17:26    Post subject: Define EXE Version Reply with quote

Does anyone here know how to define a program's version number? I need it to be displayed in the File Properties Dialog Box, but I can't find information anywhere (Yes, I Googled and MSDN'd it). It seems that it would be a #define, but I don't know the "magic keyword" to get it working.

Any help would be appreciated. Thanks.
 
Back to top
View user's profile
zerospeed

PostPosted: Oct 04, 2006 17:55    Post subject: Re: Define EXE Version Reply with quote

Coviti wrote:
Does anyone here know how to define a program's version number? I need it to be displayed in the File Properties Dialog Box, but I can't find information anywhere (Yes, I Googled and MSDN'd it). It seems that it would be a #define, but I don't know the "magic keyword" to get it working.

Any help would be appreciated. Thanks.


Is not so simple :-P

You will need a resource file holding the VERSIONINFO structure.

I'll suggest take a look at this project (Auto Windows Resource) at CodeProject.

HTH,

Zero
 
Back to top
View user's profile
MichaelW
Hero
PostPosted: Oct 04, 2006 20:02    Post subject: Reply with quote

This is a quick and dirty example of a resource definition that specifies version information that will display in the file-properties dialog.
Code:

#define VI 1 ;must be 1

VI VERSIONINFO

FILEVERSION 1,2,3,4
PRODUCTVERSION 1,2,3,4
{
 BLOCK "StringFileInfo"
 {
  BLOCK "04090000" ;0409=lang U.S.English,0000=charset 7-bit ASCII
  {
  VALUE "CompanyName","CompanyName\000"
  VALUE "FileDescription", "FileDescription\000"
  VALUE "FileVersion", "0.1.2.3\000"
  VALUE "InternalName", "InternalName\000"
  VALUE "OriginalFilename", "OriginalFilename\000"
  VALUE "ProductName","ProductName\000"
  VALUE "ProductVersion","0.1.2.3\000"
  VALUE "LegalCopyright","Copyright © duh 2101\000\000"
  }
 }
}
 

MSDN VERSIONINFO Resource
 
Back to top
View user's profile
xterm

PostPosted: Oct 05, 2006 14:40    Post subject: Reply with quote

@MichaelW
Works great, thank you!

@anyone who is interested
Save MichaelWs resource code as 'myversion.rc', then convert it with 'GoRC.exe', (from 'C:\FreeBASIC\bin\win32\GoRC.exe) to a .res file:

GoRC.exe myversion.rc

After that compile it together with the main program in the commandline:

fbc mymainprogram.bas myversion.res
 
Back to top
View user's profile
MichaelW
Hero
PostPosted: Oct 05, 2006 17:10    Post subject: Reply with quote

Or just include the .rc file on the FBC command line :)
 
Back to top
View user's profile
xterm

PostPosted: Oct 05, 2006 18:17    Post subject: Reply with quote

MichaelW wrote:
Or just include the .rc file on the FBC command line :)


Didnīt know that, but it definitely makes sense.

@anyone who might be interested
During testing this I found out that I could not combine a version information, (version.rc), and a program icon, (icon.rc), by just concatenating them in the commandline:

fbc myprogram.bas version.rc icon.rc

but it works if I combine the contents of the two .rc files in a new .rc file:

Code:

FB_PROGRAM_ICON ICON myicon.ico

#define VI 1 ;must be 1

VI VERSIONINFO

FILEVERSION 1,2,3,4
PRODUCTVERSION 1,2,3,4
{
 BLOCK "StringFileInfo"
 {
  BLOCK "04090000" ;0409=lang U.S.English,0000=charset 7-bit ASCII
  {
  VALUE "CompanyName","CompanyName\000"
  VALUE "FileDescription", "FileDescription\000"
  VALUE "FileVersion", "0.1.2.3\000"
  VALUE "InternalName", "InternalName\000"
  VALUE "OriginalFilename", "OriginalFilename\000"
  VALUE "ProductName","ProductName\000"
  VALUE "ProductVersion","0.1.2.3\000"
  VALUE "LegalCopyright","Copyright © duh 2101\000\000"
  }
 }
}


Last edited by xterm on Oct 05, 2006 20:13; edited 1 time in total
 
Back to top
View user's profile
coderJeff
Site Admin
PostPosted: Oct 05, 2006 19:32    Post subject: Reply with quote

Or create an rc file that includes other rc files:
Code:
/* example: myapp.rc */
#include "icon.rc"
#include "version.rc"
 


and allows sharing of resources between projects.
 
Back to top
View user's profile Send e-mail Visit poster's website
bobsobol

PostPosted: Jul 19, 2009 21:28    Post subject: Manifest Resource Reply with quote

I can get all of that to work, but I also need to include a Manifest in order not to have even a command line program objected to as "Unknown file" when run on Windows 6 or 7, and the first time it is run under XP.

This is what I have for my Manifest:-
Code:
IDR_MANIFEST RT_MANIFEST MOVEABLE PURE
{
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <security>
         <requestedPrivileges>
            <requestedExecutionLevel
               level="asInvoker"
               uiAccess="False"/>
         </requestedPrivileges>
      </security>
   </trustInfo>
</assembly>
}


But the Resource Compiler throws out "File not found" at the first open curly brace. "{"

This resource script is produced automatically in another development studio, so I don't really understand the correct syntax for .RC files sufficiently to correct the syntax error.

Anybody know a good solution?

Oh wait... I figured it out.

Save the Manifest (just the bit between the curly braces) as Manifest.xml, and replace all of that that I gave above with the line:-
Code:
1 MANIFEST "Manifest.xml"

That gives me an executable with a valid security descriptor for Windows 6 or 7. ^_^
 
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    freebasic.net Forum Index -> Windows All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



sf.net phatcode