Link to home
Start Free TrialLog in
Avatar of nnbbb09
nnbbb09

asked on

Change version resource info outside of the IDE

Does anyone know of a way of changing the version info that Delphi uses when building projects. I assumed that it was all stored in the .dof file but any changes I make to this file (with Notepad) are not reflected when the projected is reloaded into Delphi or when the project is built.
I'm building an application that uses the command line compiler dcc32.exe and need to give the user the ability to change version info prior to building.

Thanks

Jo
Avatar of simonet
simonet
Flag of Brazil image

The version info is, any other resource, stored in a .RES file.

What happens is that everytime you build a project from the IDE, Delphi will rebuild the .RES file based on what you have chosen in the version page.

One option, and which is the one I believe you are looking for, is not to let Delphi create the version resource. Instead, use an explicit version resource file (.RES) and let your users edit the version info as they will - without needing the Delphi IDE.

I have built a tool that does exactly that: Versioneer:

http://www.bhnet.com.br/~simonet/devtools.htm

Versioneer creates a .RES file which you can link to your project by simply using

{$R someversionfile.RES}

It also lets you edit the version information from its interface, and then recreates the RES file.

>give the user the ability to change version info prior to building.

Just let your users use Versioneer.

Yours,

Alex

Avatar of nnbbb09
nnbbb09

ASKER

Alex,

Thanks for pointing out that the info is stored in the .res file. I should have thought of that myself :-)

However we need to provide the ability to change the version number in the res file Delphi creates from within our own application (rather than using an external program). Do you know of any routines that might accomplish this.

thanks

Jo
This program changes version info in executable file

var
        fh,size,hs,h:integer;
        p:pchar;
begin
        h:=loadlibrary('yourfile.exe');
        hs:=findresource(h,makeintresource(1),RT_VERSION);
        p:=lockresource(loadresource(h,hs));
        {change p this is a version infromation i don't know the format of the version info}
        size:=sizeofresource(h,hs);
        fh:=beginupdateresource('yourfile.exe',false);
        updateresource(fh,RT_VERSION,makeintresource(1),0,p,size);
        endupdateresource(fj,false);
        freelibrary(h);
        freemem(p);
end;
Sorry this is the correct one

var
       fh,size,hs,h:integer;
       p:pchar;
begin
       h:=loadlibrary('yourfile.exe');
       hs:=findresource(h,makeintresource(1),RT_VERSION);
       p:=lockresource(loadresource(h,hs));
       {change p this is a version infromation i don't know the format of the version info}
       size:=sizeofresource(h,hs);
freelibrary(h);      
fh:=beginupdateresource('yourfile.exe',false);
       updateresource(fh,RT_VERSION,makeintresource(1),0,p,size);
       endupdateresource(fj,false);
       freemem(p);
end;
>      {change p this is a version infromation i don't know the format of the version info}

!!!!

This doesn't help much here, does it?!
I just don't know the format of version string
Avatar of nnbbb09

ASKER


Thanks for the comments. However, it's the .res file I need to edit rather than a .exe

Jo
download component whch handles *.res files
http://www.torry.net/vcl/system/res/tpresexp.zip
ASKER CERTIFIED SOLUTION
Avatar of simonet
simonet
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nnbbb09

ASKER

Alex,

Thanks. I think I'll accept your last comment as the answer. One more question though what does the statement BLOCK "040904E4" mean in the RC file

Jo
There's a much easier way if all you need is to set the version info ... I downloaded a small app a while back which does just this, changes the version info in ANY executable.

It comes in handy sometimes.

(The 040904E4 in the above is the language/charset codes).
nnbb09, sorry for the delay.

Hamlet is right about the "040904E4" statement above.

The 0409 is the hexadecimal for 1033, which is English (US) language.  

The 04e4 is the hexadecimal code for 1252, which is Latin-1 character set.

But what does that mean?
It means that you can have several different blocks of resources in your .RC file, one for each language you want to support. Every user's Windows has a default language and character set (this is a user-defined setting and can be changed in the "International" control panel applet).

When Windows looks for a resource in an executable, it first looks for the ones that match its language and charset. If one is found, then that one is loaded, otherwise it starts looking for resources that match either the charset or the language (language first). if none is found that it looks for the US-English/Latin-1 and loads that if found, otherwise it loads whatever it finds there.

Other possible values can be found in the file Win32SDK.HLP (which can be already installed in your system or in the Delphi 4/5 CD), under the following help topics:

ANSI Code-Page Identifiers
OEM Code-Page Identifiers
Code-Page Identifiers
Language Identifiers and Locales

Just remember that in the RC file the values must be 4-digit hexadecimal numbers.

Yours,

Alex