Question

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 ?

Was it helpful?

Solution

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}

OTHER TIPS

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).

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top