4

I have a software made with Delphi 2010 and it is required to be used from two different departments both of them share the same data and same UI except for some changes like hide/add buttons, forms and grid columns. Therefore it is required to have two versions of the same application.

It is not possible to prompt the user on application startup to select a department I must use separate EXEs.

What is the best approach (concept) to do that within Delphi 2010 or XE3 (will upgrade later) ? Is it possible to compile with different exe names ?

Filburt
  • 17,626
  • 12
  • 64
  • 115
zac
  • 4,495
  • 15
  • 62
  • 127
  • 4
    There are alternatives in between a prompt on startup and an entirely different EXE. Why not a configuration or settings file? – J... Mar 28 '13 at 13:02
  • 1
    if there is a login for the software its easily solved by setting user rights for the application. or as stated above with a config or settings file. Or make 2 different projects from it. But that would mean that when you make a change you will have to do it twice. – Teun Pronk Mar 28 '13 at 13:04
  • tell me more please about using config or setting files with different compiled EXE – zac Mar 28 '13 at 13:18
  • Is it possible to save same app into two Delphi project files *.dproj and share same files to compile to two EXE and then read settings from file ? – zac Mar 28 '13 at 13:20
  • 4
    Config file would be a single EXE solution. Read the file at startup and show the appropriate version of the forms. That's how I would do it. – David Heffernan Mar 28 '13 at 13:23
  • Configuration is something that almost every program you have ever used provides. Windows itself is chock full of configuration options, and so is Delphi. I am surprised that Welliam hasn't heard of a configuration file or registry key before.... Maybe a big Delphi book would help you find your way, Welliam! – Warren P Mar 28 '13 at 21:52

4 Answers4

9

Sounds like a maintenance nightmare, so please consider other solutions such as suggested in the comments like a login or settings file.

If you do want to make separate exe's then you could use compiler defines and based on the define in/exclude parts of the code:

Add a new configuration:

enter image description here

Add the define to the configuration: enter image description here

Use the define in your code:

{$IFNDEF ADVANCED}
   // Remove Event Handler
   Button1.OnClick := nil;
   // Hide Button
   Button1.Visible := False;
{$ENDIF}
Remko
  • 7,214
  • 2
  • 32
  • 52
9

I can think of few solutions to this:

  • Provide an INI file with your release application (or create a Registry key on the client machine) to specify/determine what department your application serves. then read the values via TIniFile or TRegistry. e.g. an INI file (MyApp.ini):

    [Options]
    Department=Sales

  • Create a shortcut to your program and use parameters e.g. "MyApp.exe /sales" or "MyApp.exe /support" (ParamStr(1) will tell you if it's /sales vs. /support department)

  • Use 2 separate project files, and in each project options define your Conditionals directive for example SALES or SUPPORT, then in your code use {$IFDEF SALES}...{$ENDIF} - Using this options it is very important to fully rebuild all project units. (I have a pre-build script which deletes the project *.dcu files before I compile it).

TLama
  • 75,147
  • 17
  • 214
  • 392
kobik
  • 21,001
  • 4
  • 61
  • 121
0

You need to have permission system into your application, which could be customized to different groups and profiles, and you can assign roles or specific permissions for all end users who will use the application, you can develop it your self, or you can rely on third party such as TMS Security System

enter image description here

Mohammed Nasman
  • 10,992
  • 7
  • 43
  • 68
0

One possible thing to do is make the first project. Make your application.

Then make a second project in the same folder and add all units from the first project to that project.

Now in your second project, if you only need small changes, you can for instance derive a new class from your mainform in your first project, and put the changes on that.

That way you have 2 exes but with a shared codebase.

Pieter B
  • 1,874
  • 10
  • 22