Solved

Change .exe name w/in delphi

Posted on 1999-01-27
15
3,099 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
 

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now