Solved

Change .exe name w/in delphi

Posted on 1999-01-27
15
3,148 Views
Last Modified: 2011-05-02
Is there a way to specify the name of the exe that you want with the project source?  The only way I know how to do this now is rename the project.  Is there an easier way?
0
Comment
Question by:regsoft
  • 5
  • 4
  • 3
  • +3
15 Comments
 
LVL 5

Expert Comment

by:heathprovost
ID: 1363573
I dont really know of a way to do this other then the one you gave.  But there is no reason why you cant rename the exe file after you have compiled.  I do this all the time.

Heath
0
 

Author Comment

by:regsoft
ID: 1363574
Yes - I do that as well - I just thought there would be a way like when you compile a Screen Saver - you can add  {$E SCR}  to make the .exe (the extension)  be a .scr .  I assumed there may be a way to change the actual .exe filename.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1363575
?Why do you need that?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:regsoft
ID: 1363576
Each new release of my app - I like to put the version in the .exe name MFK4.0.0.exe
I can then have all the previous .exe named accordingly.  Right now after I compile, I re-name it.

0
 
LVL 44

Expert Comment

by:bruintje
ID: 1363577
Hi RegSoft,

Suggestion,
Maybe a batch file?
Make a commandline compiler batchfile where you rename the resulting exe in the end?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1363578
Try reading a variable from a file.... for example use an INI file and each application you write just write it's title as the item unde category and then assign a value for that item.,.. the use the initializatio nto read that value in and change the name of the application...

for example...

//MyIniFile.ini
[Titles]
Last Shareware=v1.2

then you read that value and your title would be as follows...

Last Shareware v1.2

and so on..

you use the initialization to set the aplication's name...

............the code goes here,,,,,
//the you do this,,,
initialization
  Application.ExeName := TheNameYouReadFromYourIniFile;

I've also seen Delphi exeperts (i think that's what they are called) that when you run the program they can change the version and all that in design time.... everytime you compile it changes the name.. you could try looking for them on DSP, Torry's pages, and so on... I don't exactly remember where I saw it, but if I find something I;ll let you know..

-Viktor
--Ivanov
0
 

Author Comment

by:regsoft
ID: 1363579
I thought there was an easy way to it like {$E SCR}  (makes the .exe a .scr at compile time)

Thats what I was looking for.

Thanks anyways
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1363580
>>>viktornet : Correct me if I'm wrong on this but I guess you have to change your ini everytime before you run or not? Think that isn't that much of a difference then changing the name of your exe.

>>>regsoft : When you introduce some intelligent counter object that's reading the inifile from viktor and updating the version counter with one, just like the build in the IDE, and writing that value in your inifile then I think this should work.
:O)Always happY.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1363581
yeah, the problem with this is that you should change the INI everytime... but at least you don't do it manually and have Delphi code to change it for you,,,,
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1363582
Hmmmm....didn't see that post coming did some time traveling again.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1363583
Maybe I should change my machine time, but I get my posts not there in the void in time, even if regsoft won't use this, think we got a workable solution here.

Put some information and your exename in an inifile.
Read the version number when you build / compile / run.
Let a counter object change the version number.
Write the new name.
And read the new name into your executable.

Think this will work for me anyway,
:O)Good nighT
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1363584
regsoft, i don't know of such a way except writing your expert for Delphi that will do the job... it is quite difficult to do that though.. I suggest you use something similar to what I proposed...

-Viktor
--Ivanov
0
 
LVL 1

Accepted Solution

by:
zwarte earned 50 total points
ID: 1363585
Correct me if I am wrong, but won't your version change everytime you do a build all, or run your program, so working with the inifile and the counter won't do you any good.
including it in the compiler directives won't help either 'cause you'd have to modify and rebuild your *.scr file every time.
using a batch file won't rename your file right unless you modify your batch file all the time.

My suggestion is to write a small application in delphi simply checking the directory with all your *.exe's and then looking for the last version. Add 1 to the version, and then rename and copy your exe from your working directory to your *.exe directory.

general structure would be:

GetFilesFromExeDir:Tstringlist;
{gets all the filenames from the dir where you keep your exe's}
GiveHighestVersionNumber(Listing:Tstringlist):string;
{looks at all the filenames and extracts the highest version number}
AddVersion(version:String);
{copies your exe from your working directory to the directory where you keep your *.exe's and modifies the name to bear a higher version number}

Var
   a:TstrinList;
   version:string;
Begin
   a:=TStringList.create;
   a:=GetFilesFromExeDir;
   version:=GiveHighestVersionNumber(a);
   AddVersion(version);
   a.free;.
end;

This program will allow you to make a new build of your exe whenever you like and you'll be sure that the exe has a higher version number (you might want to consider including a date or time in the name)

I could work out all the procedures, but I think you get the point ;-)

Tom
0
 

Author Comment

by:regsoft
ID: 1363586
Not what I was looking for - but it looks like that something like that is the only way.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1363587
Indeed:O)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question