www.pudn.com > LANUpdate_Lite_v0.1_EN_src.zip > Unit1-Linux.pas


unit Unit1; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, ComCtrls, CHButton, ExtCtrls, StdCtrls, Registry, IniFiles, 
  Buttons, Menus; 
 
type 
  TForm1 = class(TForm) 
    Titel: TStaticText; 
    Prog2: TCHButton; 
    Prog1: TCHButton; 
    cp: TCHButton; 
    install: TCHButton; 
    Prog1panel: TPanel; 
    Beenden: TCHButton; 
    TInfos1: TStaticText; 
    Infos1: TStaticText; 
    Prog2panel: TPanel; 
    TInfos2: TStaticText; 
    Infos2: TStaticText; 
    Prog2a: TCHButton; 
    Prog1a: TCHButton; 
    MainMenu1: TMainMenu; 
    Datei1: TMenuItem; 
    Extras1: TMenuItem; 
    N1: TMenuItem; 
    Bearbeiten1: TMenuItem; 
    Beenden1: TMenuItem; 
    Installieren1: TMenuItem; 
    Optionen1: TMenuItem; 
    ber1: TMenuItem; 
    Animate1: TAnimate; 
    procedure BeendenClick(Sender: TObject); 
    procedure FormCreate(Sender: TObject); 
    procedure Prog2Click(Sender: TObject); 
    procedure Prog1Click(Sender: TObject); 
    procedure installClick(Sender: TObject); 
    procedure FormShow(Sender: TObject); 
    procedure ber1Click(Sender: TObject); 
    procedure Optionen1Click(Sender: TObject); 
  private 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  Form1: TForm1; 
 
implementation 
uses About, Config; 
VAR Prog1datei, Prog1name, Prog1version, Prog1datum, Prog2datei, Prog2name, Prog2version, Prog2datum:string; 
    isnonUpdate : bool = False; 
    startuperror: bool = False; 
    Prog1Update, Prog2Update, error : bool; 
 
 
{$R *.dfm} 
 
procedure loadUpdateInfo; 
VAR ini : TIniFile; 
Begin 
      ini := TIniFile.Create('\\Server\Update\LUpLite.cfg'); 
      If ini.existString Then  
        Begin 
          Prog1datei := ini.ReadString('Prog1','Datei',''); 
          Prog1name := ini.ReadString('Prog1','Name',''); 
          Prog1version := ini.ReadString('Prog1', 'Version', ''); 
          Prog1datum := ini.ReadString('Prog1', 'Datum', ''); 
          Prog2datei := ini.ReadString('Prog2','Datei',''); 
          Prog2name := ini.ReadString('Prog2', 'Name', ''); 
          Prog2version := ini.ReadString('Prog2', 'Version', ''); 
          Prog2datum := ini.ReadString('Prog2', 'Datum', ''); 
          error := false; 
        End 
      else 
        error := true; 
End; 
 
function checkNewProgramm:integer; 
var regist: TRegistry; 
Begin 
  regist := TRegistry.Create; 
  regist.RootKey:= HKEY_LOCAL_MACHINE; 
  regist.OpenKey('Software\LES\LANUpdate Lite', true); 
  error := loadUpdateInfo; 
  If error = false Then 
    Begin 
      If regist.ReadString('Prog1Name') = Prog1name Then 
        IF (regist.ReadString('Prog1Version') <> Prog1version) or (regist.ReadString('Prog1Version') = Prog1version) Then 
          IF regist.ReadString('Prog1datum') <> Prog1datum Then 
            Begin 
              Form1.Infos1.Caption := ''; 
              Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1name + #10 + #10; 
              Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1version + #10 + #10; 
              Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1datum; 
              Form1.Prog1.Font.Color := clred; 
              Form1.Prog1a.Font.Color := clred; 
              Prog1Update := True; 
              Form1.Animate1.visible := true; 
              isnonUpdate := False; 
            End 
      Else 
        Begin 
          Form1.Infos1.Caption := ''; 
          Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1name + #10 + #10; 
          Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1version + #10 + #10; 
          Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1datum; 
          Form1.Prog1.Font.Color := clWindowText; 
          Form1.Prog1a.Font.Color := clWindowText; 
          Prog1Update := False; 
          isnonUpdate := True; 
        End 
    Else 
      Begin 
        Form1.Infos1.Caption := ''; 
        Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1name + #10 + #10; 
        Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1version + #10 + #10; 
        Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1datum; 
        Form1.Prog1.Font.Color := clWindowText; 
        Form1.Prog1a.Font.Color := clWindowText; 
        Prog1Update := False; 
        isnonUpdate := True; 
      End; 
  If regist.ReadString('Prog2Name') = Prog2name Then 
    IF regist.ReadString('Prog2Version') <> Prog2version Then 
      IF regist.ReadString('Prog2Datum') <> Prog2datum Then 
          Begin 
            Form1.Infos2.Caption := ''; 
            Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2name + #10 + #10; 
            Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2version + #10 + #10; 
            Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2datum; 
            Form1.Prog2.Font.Color := clred; 
            Form1.Prog2a.Font.Color := clred; 
            Prog2Update := True; 
            Form1.Animate1.Visible := true; 
            isnonUpdate := isnonUpdate and False; 
          End 
      Else 
        Begin 
          Form1.Infos2.Caption := ''; 
          Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2name + #10 + #10; 
          Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2version + #10 + #10; 
          Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2datum; 
          Form1.Prog2.Font.Color := clWindowText; 
          Form1.Prog2a.Font.Color := clWindowText; 
          Prog2Update := False; 
          isnonUpdate := isnonUpdate and True; 
        End 
    Else 
      Begin 
        Form1.Infos2.Caption := ''; 
        Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2name + #10 + #10; 
        Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2version + #10 + #10; 
        Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2datum; 
        Form1.Prog2.Font.Color := clWindowText; 
        Form1.Prog2a.Font.Color := clWindowText; 
        Prog2Update := False; 
        isnonUpdate := isnonUpdate and True; 
      End; 
  If isnonUpdate Then 
    Begin 
      Form1.Titel.Caption := 'Kein Update notwendig'; 
      Form1.Titel.Color := clgreen; 
    End; 
  End 
  else result := 1; 
End; 
 
procedure TForm1.BeendenClick(Sender: TObject); 
begin 
  close; 
end; 
 
procedure firstexecute; 
Begin 
  loadUpdateInfo; 
  Form1.Infos1.Caption := ''; 
  Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1name + #10 + #10; 
  Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1version + #10 + #10; 
  Form1.Infos1.Caption := Form1.Infos1.Caption + Prog1datum; 
  Form1.Prog1.Caption := Prog1name; 
  Form1.Prog1a.Caption := Prog1name; 
  Form1.Infos2.Caption := ''; 
  Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2name + #10 + #10; 
  Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2version + #10 + #10; 
  Form1.Infos2.Caption := Form1.Infos2.Caption + Prog2datum; 
  Form1.Prog2.Caption := Prog2name; 
  Form1.Prog2a.Caption := Prog2name; 
End; 
 
procedure TForm1.FormCreate(Sender: TObject); 
begin 
  checkNewProgramm; 
  If error = false then 
    Begin 
      firstexecute; 
      animate1. 
      IF not(Prog1Update) and (Prog2Update) Then Prog2Click(Form1); 
    End 
  else 
    Begin 
      firstexecute; 
      showmessage ('Momentan kann die Verbindung zum Update-Server nicht aufgebaut werden, versuchen sie es bitte später nochmal. (Bei Anhäufung dieser Fehlermeldung melden Sie sich bitte bei Ihrem Netz-Administrator)'); 
      startuperror := true; 
    End; 
end; 
 
procedure TForm1.Prog2Click(Sender: TObject); 
begin 
  Prog2a.Visible := True; 
  Prog2.Visible := False; 
  Prog2Panel.Visible := True; 
  Prog1a.Visible := False; 
  Prog1.Visible := True; 
  Prog1Panel.Visible := false; 
  If Prog2Update then 
    Begin 
      Form1.Titel.Caption := 'Neue Updates verfügbar !!!'; 
      Form1.Titel.Color := clred; 
      Animate1.Visible := true; 
    End 
  else 
    Begin 
      Form1.Titel.Caption := 'Kein Update notwendig'; 
      Form1.Titel.Color := clgreen; 
      Animate1.Visible := false; 
    End; 
end; 
 
procedure TForm1.Prog1Click(Sender: TObject); 
begin 
  Prog2a.Visible := False; 
  Prog2.Visible := True; 
  Prog2Panel.Visible := False; 
  Prog1a.Visible := True; 
  Prog1.Visible := False; 
  Prog1Panel.Visible := True; 
  If Prog1Update then 
    Begin 
      Form1.Titel.Caption := 'Neue Updates verfügbar !!!'; 
      Form1.Titel.Color := clred; 
      Animate1.Visible := true; 
    End 
  else 
    Begin 
      Form1.Titel.Caption := 'Kein Update notwendig'; 
      Form1.Titel.Color := clgreen; 
      Animate1.Visible := false; 
    End; 
end; 
 
procedure TForm1.installClick(Sender: TObject); 
VAR regist: TRegistry; 
    exe : PChar; 
Begin 
  regist := TRegistry.Create; 
  regist.RootKey:= HKEY_LOCAL_MACHINE; 
  regist.OpenKey('Software\LES\LANUpdate Lite', true); 
  If Prog1a.Visible Then 
    Begin 
      regist.WriteString('Prog1Datei',Prog1datei); 
      regist.WriteString('Prog1Name', Prog1name); 
      regist.WriteString('Prog1Version', Prog1version); 
      regist.WriteString('Prog1Datum', Prog1datum); 
      exe := Pchar('\\server\Update\' + Prog1datei); 
      WinExec(exe,SW_NORMAL); 
    End; 
  If Prog2a.Visible Then 
    Begin 
      regist.WriteString('Prog2Datei',Prog2datei); 
      regist.WriteString('Prog2Name', Prog2name); 
      regist.WriteString('Prog2Version', Prog2version); 
      regist.WriteString('Prog2Datum', Prog2datum); 
      exe := Pchar('\\server\Update\' + Prog2datei); 
      WinExec(exe,SW_NORMAL); 
    End; 
  checkNewProgramm; 
  IF not(Prog1Update) and (Prog2Update) Then Prog2Click(Form1); 
  IF (Prog1Update) and not(Prog2Update) Then Prog1Click(Form1); 
end; 
 
procedure TForm1.FormShow(Sender: TObject); 
begin 
  IF isnonUpdate Then close; 
  {If startuperror = true then close;} 
end; 
 
procedure TForm1.ber1Click(Sender: TObject); 
begin 
 Aboutbox.ShowModal; 
end; 
 
procedure TForm1.Optionen1Click(Sender: TObject); 
begin 
  Configure.ShowModal; 
end; 
 
end.