Board index » delphi » Setup program (source, long)

Setup program (source, long)

Dear listmembers:

from time to time people ask how to write a setup program for their  
applications.

I've just written one, and I thought it might be interesting for some
to  
get the code, so that they can derive their own setup routines from
that.

The actual application for which it was designed is (of course) not  
included, instead I included a little 'dummy'-program.

I hope it is useful to at least some of the listmembers.

Best Regards, N. Hartkamp

Adress:
Dr.N.Hartkamp, Klinik fuer Psychotherapie der Universitaet
P.O.Box 12 05 10                        40605 Duesseldorf
Phone: +49-211-922-4722                 FAX:   +49-211-922-4707
e-Mail:hartk...@uni-duesseldorf.de (office)
MBX:   N-HARTK...@NADESHDA.GUN.DE  (private)

{##########################################################}
{ this is a setup program for an application I wrote.
  Maybe it's useful to others who are about to write their
  own Setup-programs.

  Dr. Norbert Hartkamp
  hartk...@uni-duesseldorf.de
  n-hartk...@nadeshda.gun.de

Quote
}

{############################################################################}
{file setupscl.pas}
program Setupscl;

uses
  Forms,
  Setupsc1 in 'SETUPSC1.PAS' {Form1};

{$R *.RES}

begin
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

{############################################################################}
{file setupsc1.pas}
unit Setupsc1;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, LZExpand, DdeMan;

const ProgName   = 'SCL90.EXE';
      LZProgName = 'SCL90.EX_';
type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Panel1: TPanel;
    Label1: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label2: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Panel2: TPanel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    ProgrammpfadEdit: TEdit;
    DatenpfadEdit: TEdit;
    Label11: TLabel;
    Label12: TLabel;
    Panel3: TPanel;
    Label14: TLabel;
    AuswerterEdit: TEdit;
    Label15: TLabel;
    Inst1Edit: TEdit;
    Inst2Edit: TEdit;
    Inst3Edit: TEdit;
    CheckBox1: TCheckBox;
    Panel4: TPanel;
    Image1: TImage;
    Label13: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    DdeClientConv1: TDdeClientConv;
    Image2: TImage;
    Label19: TLabel;
    Label20: TLabel;
    Label18: TLabel;
    Panel5: TPanel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    procedure FormPaint(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    DialogNo            : byte;
    WinDir              : array [0..144] of char;
    Programmverzeichnis : string[127];
    Datenverzeichnis    : string[127];
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormPaint(Sender: TObject);
var   Rows, Height:Integer;
begin
  Height:=(ClientHeight + 255) div 256;
  for Rows := 0 to 255 do
  begin
    Canvas.Brush.Color := RGB(0,0,Rows);

Canvas.FillRect(Rect(0,(255-Rows)*Height,ClientWidth,((255-Rows)+1)*Height));
  end;
  Canvas.Font.Size := 32;
  Canvas.Font.Color:= clBlack;
  Canvas.Brush.Style := bsClear;
  Canvas.TextOut(13, 13, 'Setup SCL-90-Auswertung');
  Canvas.Font.Color:= clYellow;
  Canvas.TextOut(10, 10, 'Setup SCL-90-Auswertung');
  Canvas.Font.Size := 11;
  Canvas.Font.Style:= [fsBold];
  Canvas.Font.Color:= clWhite;
  Canvas.TextOut(10, ClientHeight-(ClientHeight div 20), '?
N.Hartkamp, 1996');
end;

procedure TForm1.FormCreate(Sender: TObject);
var fileHandle: THandle;
    fileBuffer: Array [0..40] of Char;
begin
  BorderStyle := bsNone;
  WindowState := wsMaximized;
  BitBtn1.Top := trunc(ClientHeight * 0.90);
  BitBtn2.Top := trunc(ClientHeight * 0.90);
  BitBtn1.Left:= trunc(ClientWidth  * 0.80);
  BitBtn2.Left:= trunc(ClientWidth  * 0.60);
  DialogNo := 0;
  FillChar(WinDir, SizeOf(WinDir), #0);
  GetWindowsDirectory(WinDir, 144);
  ProgrammpfadEdit.Text := StrPas(WinDir);
  ProgrammpfadEdit.Text := ProgrammpfadEdit.Text[1] + ':\SCL90R';
  DatenpfadEdit.Text := ProgrammpfadEdit.Text;
  AuswerterEdit.Text := 'Anwendername';

  { Get user name and company name }
  fileHandle := LoadLibrary('USER');

  if fileHandle >= HINSTANCE_ERROR then begin
    If LoadString(fileHandle, 514, @fileBuffer, 40) <> 0 Then
       AuswerterEdit.Text := StrPas(fileBuffer);
    FreeLibrary(fileHandle);
  end;

  Inst1Edit.Text := 'Bezeichnung der Institution';
  Inst2Edit.Text := 'Bezeichnung der Institution (Fortsetzung)';
  Inst3Edit.Text := '- z.B.: Angabe der Abteilung -';
  CheckBox1.Checked := true;

  Panel1.Left := (ClientWidth  div 2) - (Panel1.Width  div 2);
  Panel1.Top  := (ClientHeight div 2) - (Panel1.Height div 2);

  Panel2.Left := (ClientWidth  div 2) - (Panel2.Width  div 2);
  Panel2.Top  := (ClientHeight div 2) - (Panel2.Height div 2);

  Panel3.Left := (ClientWidth  div 2) - (Panel3.Width  div 2);
  Panel3.Top  := (ClientHeight div 2) - (Panel3.Height div 2);

  Panel4.Left := (ClientWidth  div 2) - (Panel4.Width  div 2);
  Panel4.Top  := (ClientHeight div 2) - (Panel4.Height div 2);

  Panel5.Left := (ClientWidth  div 2) - (Panel5.Width  div 2);
  Panel5.Top  := (ClientHeight div 2) - (Panel5.Height div 2);
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
var aResultStr : array[0..144] of char;
    strIniPath : array[0..144] of char;
    ResultStr  : string[144];
    fromStruct : TOFStruct;
    toStruct   : TOFStruct;
    ret        : word;
    fromHandle : integer;
    toHandle   : integer;
    BDEOk      : boolean;
    CurPath    : string[144];
    Ok         : Longint;
    i          : word;
    DDE_Link   : Boolean;
    Macro      : string;

  function iif(cond : boolean; exp1, exp2 : string) : string;
  begin
    if cond then result := exp1 else result := exp2;
  end;

begin
  if DialogNo = 0 then begin
    ret := GetProfileString('IDAPI', 'CONFIGFILE01', 'NIX',
aResultStr, 80);
    ResultStr := StrPas(aResultStr);
    BDEOk := (ResultStr <> 'NIX') and FileExists(ResultStr);
    if not BDEOk then begin
      Panel1.Hide;
      MessageDlg('Installationsfehler:'+#13#13+
                 'Bevor Sie das SCL-90 Auswertungsprogramm
installieren'+#13+
                 'k?nnen, mssen Sie die Database-Engine
installieren.'+#13#13+
                 'Fhren Sie dazu das Program SETUP.EXE von'+#13+
                 'der BDE-Diskette 1 aus.', mtError, [mbOk], 0);
      Close;
    end;
  end;
  Inc(DialogNo);
  case DialogNo of
    1: begin
         Panel1.Hide;
         Panel2.Show;
         ProgrammpfadEdit.SetFocus;
       end;
    2: begin
         GetDir(0, CurPath);
         Ok  := 0;
         ret := IOResult;
         {$I-}
         ChDir(ProgrammpfadEdit.Text);
         if IOResult <> 0 then ok := 1;
         ChDir(DatenpfadEdit.Text);
         if IOResult <> 0 then if ok = 0 then ok := 2 else ok := 3;
         if ok <> 0 then begin
           case ok of
             1 : CurPath := 'Das Programmverzeichnis ist ';
             2 : CurPath := 'Das Datenverzeichnis ist ';
             3 : CurPath := 'Programm- und Datenverzeichnis sind ';
           end;
           Panel2.Hide;
           if MessageDlg(CurPath + 'nicht vorhanden'+#13+
                        iif(ok=3,'Sollen die Verzeichnisse ', 'Soll
das Verzeichnis ') +
                        'angelegt werden?', mtConfirmation, [mbYes,
mbNo], 0) = mrNo
             then begin
               Panel2.Show;
               Dec(DialogNo);
               if odd(Ok) then ProgrammpfadEdit.SetFocus
                          else DatenpfadEdit.SetFocus;
             end else begin
               MkDir(ProgrammpfadEdit.Text);
               MkDir(DatenpfadEdit.Text);
               DialogNo := 2;
               ret := IOResult;
               Ok  := 0;
             end;
         end;
         ChDir(CurPath);
         if Ok = 0 then begin
           Panel2.Hide;
           Panel3.Show;
           AuswerterEdit.SetFocus;
         end;
       end;
    3: begin
         Panel3.Hide;
         Panel4.Show;
         Invalidate;
         Application.ProcessMessages;
         ResultStr := ProgrammpfadEdit.Text;
         if ResultStr[length(ResultStr)] <> '\' then ResultStr :=
ResultStr + '\';
         StrPCopy(strIniPath, ResultStr + 'SCL90.INI');
         WritePrivateProfileString('Passwort', 'Passwort', '??',
strIniPath);

         StrPCopy(aResultStr, DatenpfadEdit.Text);
         WritePrivateProfileString('Vorgaben', 'Datenpfad',
aResultStr, strIniPath);

         StrPCopy(aResultStr, Inst1Edit.Text);
         WritePrivateProfileString('Vorgaben', 'Inst1'    ,
aResultStr, strIniPath);

         StrPCopy(aResultStr, Inst2Edit.Text);
         WritePrivateProfileString('Vorgaben', 'Inst2'    ,
aResultStr, strIniPath);

         StrPCopy(aResultStr, Inst3Edit.Text);
         WritePrivateProfileString('Vorgaben', 'Inst3'    ,
aResultStr, strIniPath);

         StrPCopy(aResultStr, AuswerterEdit.Text);
         WritePrivateProfileString('Vorgaben', 'Auswerter',
aResultStr, strIniPath);

         WritePrivateProfileString('Vorgaben', 'TWerte',    '1',
strIniPath);

         fromHandle := LZOpenFile(LZProgName, fromStruct, OF_READ);
         ResultStr  := ProgrammpfadEdit.Text;
         if ResultStr[length(ResultStr)] <> '\' then ResultStr :=
ResultStr + '\';
         StrPCopy(aResultStr, ResultStr+ProgName);
         toHandle   := LZOpenFile(aResultStr, toStruct, OF_CREATE);
         ok := LZCopy(fromHandle, toHandle);
         if ok < 0 then begin
           case ok of
             LZERROR_BADINHANDLE  : ResultStr := 'Das Handle, das die
Quelldatei bezeichnet, ist nicht gltig.';
             LZERROR_BADOUTHANDLE : ResultStr := 'Das
...

read more »

 

Re:Setup program (source, long)


Quote
In article <4i1hhv$...@slip.net>, akl...@slip.net wrote:
>On Sat, 02 Mar 1996 21:04:15 GMT, hartk...@uni-duesseldorf.de (Norbert
>Hartkamp) wrote:

>>from time to time people ask how to write a setup program for their  
>>applications.

>>I've just written one, and I thought it might be interesting for some
>>to  get the code, so that they can derive their own setup routines from
>>that.

>Thank you.

>You just saved me much work.

>Good example of what the internet, and this newsgroup, can accomplish.

>--
>Al

How do I get the code?  Thanks.

Re:Setup program (source, long)


On Sat, 02 Mar 1996 21:04:15 GMT, hartk...@uni-duesseldorf.de (Norbert

Quote
Hartkamp) wrote:
>from time to time people ask how to write a setup program for their  
>applications.

>I've just written one, and I thought it might be interesting for some
>to  get the code, so that they can derive their own setup routines fr
>om
>that.

I am not sure how I missed this article but I would be interested in
receiving a copy of your source code so that I can compare and improve
my own.

Michael Bliesner
sca...@iea.com

Re:Setup program (source, long)


Quote
m...@mncs.maynick.com.au (Minh Luu) wrote:
>In article <4i1hhv$...@slip.net>, akl...@slip.net wrote:
>>On Sat, 02 Mar 1996 21:04:15 GMT, hartk...@uni-duesseldorf.de (Norbert
>>Hartkamp) wrote:

>>>from time to time people ask how to write a setup program for their  
>>>applications.

>>>I've just written one, and I thought it might be interesting for some
>>>to  get the code, so that they can derive their own setup routines from
>>>that.

>>Thank you.

>>You just saved me much work.

>>Good example of what the internet, and this newsgroup, can accomplish.

>>--
>>Al

>How do I get the code?  Thanks.

I need the code too.  Thanks.

Re:Setup program (source, long)


Dear listmembers:

Several listmembers asked for the source-code. It's now available at

  host:       ftp.uni-duesseldorf.de    
  directory:  /pub/local/misc
  file:       setupsou.zip

Best Regards,

N. Hartkamp

Adress:
Dr.N.Hartkamp
Klinik fuer Psychotherapie der Universitaet
P.O.Box 12 05 10
40605 Duesseldorf
Phone: +49-211-922-4722
FAX:   +49-211-922-4707
e-Mail:hartk...@uni-duesseldorf.de (office)
MBX:   N-HARTK...@NADESHDA.GUN.DE  (private)

Re:Setup program (source, long)


Quote
sca...@iea.com (Michael Bliesner) wrote:
>On Sat, 02 Mar 1996 21:04:15 GMT, hartk...@uni-duesseldorf.de (Norbert
>Hartkamp) wrote:
>>from time to time people ask how to write a setup program for their  
>>applications.

>>I've just written one, and I thought it might be interesting for some
>>to  get the code, so that they can derive their own setup routines fr
>>om
>>that.
>I am not sure how I missed this article but I would be interested in
>receiving a copy of your source code so that I can compare and improve
>my own.
>Michael Bliesner
>sca...@iea.com

I just started Delphi this week - I would appreciate a copy of your
code -  thanks

Re:Setup program (source, long)


Quote
>>On Sat, 02 Mar 1996 21:04:15 GMT, hartk...@uni-duesseldorf.de
>>>I've just written one, and I thought it might be interesting for some
>>>to  get the code, so that they can derive their own setup routines fr
>>>om
>>>that.

I would be interested in a copy of the code too..

    /     .
   /        ___
  /     /  ___/  
 /____ / /___  @ xcalibur.demon.co.uk

Re:Setup program (source, long)


Quote
esta...@mindspring.com (Edward Staley) writes:

: >I am not sure how I missed this article but I would be interested in
: >receiving a copy of your source code so that I can compare and improve
: >my own.
:
: >Michael Bliesner
: >sca...@iea.com
:
: I just started Delphi this week - I would appreciate a copy of your
: code -  thanks

For those who missed this original post (like me), and have access to
Dejanews, it can be found there - I searched for "setup program source"
after setting a filter to the comp.lang.pascal.delphi.misc newsgroup, and
it popped right up.

Now, if someone would translate the German to English for us...

**  Bill Bardon           COMPUTASSIST, Computer Consulting Services  **
**  wrbar...@gonix.com                             Elkhorn, Nebraska  **

Re:Setup program (source, long)


Quote
ro...@aly.space.infra.de (Robin Aly) wrote:
>Hallo wrbardon@gonix
>wrbardon@gonix (Bill Bardon)  meinte am 20.03.96
>zum Thema "Re: Setup program (source, long)":
> > : I just started Delphi this week - I would appreciate a copy of your
> > : code -  thanks

> > For those who missed this original post (like me), and have access to
> > Dejanews, it can be found there - I searched for "setup program source"
> > after setting a filter to the comp.lang.pascal.delphi.misc newsgroup, and
> > it popped right up.
>How do I get access to Dejanews ?
> > Now, if someone would translate the German to English for us...
>Is it written in German ?
>Robin
>---
>  <= Robin Aly (ro...@space.infra.de) (Robin Aly@2:2476/757.4) =>
>  <= My ideas are mine as long nobody says something else :-)  =>
>## CrossPoint v3.1 ##

Dear listmembers:

Several listmembers asked for the source-code. It's now available at

  host:       ftp.uni-duesseldorf.de    
  directory:  /pub/local/misc
  file:       setupsou.zip

BTW: It's written for german language application, so the text in the
dialog boxes is in german -- but anyways: the program is of course
written in Delphi! ;-)
Best Regards,

N. Hartkamp

Adress:
Dr.N.Hartkamp
Klinik fuer Psychotherapie der Universitaet
P.O.Box 12 05 10
40605 Duesseldorf
Phone: +49-211-922-4722
FAX:   +49-211-922-4707
e-Mail:hartk...@uni-duesseldorf.de (office)
MBX:   N-HARTK...@NADESHDA.GUN.DE  (private)

Re:Setup program (source, long)


Quote
ro...@aly.space.infra.de (Robin Aly) wrote:
> > Now, if someone would translate the German to English for us...
>Is it written in German ?

More seriously: If there would there be enough peolple interested to
have a "generic" version (without german text), it would be easy for
me to change the the existing aplication and to distribute it in this
generic form.

Regards, N. Hartkamp

Adress:
Dr.N.Hartkamp
Klinik fuer Psychotherapie der Universitaet
P.O.Box 12 05 10
40605 Duesseldorf
Phone: +49-211-922-4722
FAX:   +49-211-922-4707
e-Mail:hartk...@uni-duesseldorf.de (office)
MBX:   N-HARTK...@NADESHDA.GUN.DE  (private)

Other Threads