Thema: Delphi Wo ist der Fehler ?

Einzelnen Beitrag anzeigen

PsTo

Registriert seit: 16. Jun 2009
14 Beiträge
 
#11

Re: Wo ist der Fehler ?

  Alt 16. Jun 2009, 22:39
Naja, mache es net gerne, aber gut. hier der source
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, sSkinManager, Menus, StdCtrls, sButton, sEdit, acPNG, ExtCtrls,
  sLabel, sPanel, ComCtrls, sTrackBar, Registry, sMemo, Shellapi,
  DynamicSkinForm, OleCtrls, SHDocVw;

type
  TForm1 = class(TForm)
    sSkinManager1: TsSkinManager;
    OpenDialog1: TOpenDialog;
    sLabel1: TsLabel;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    sPanel1: TsPanel;
    sLabel2: TsLabel;
    sTrackBar1: TsTrackBar;
    Image1: TImage;
    Image5: TImage;
    sLabel3: TsLabel;
    Label1: TLabel;
    Label2: TLabel;
    sMemo1: TsMemo;
    MainMenu1: TMainMenu;
    test1: TMenuItem;
    test2: TMenuItem;
    procedure Image4Click(Sender: TObject);
    procedure Image3Click(Sender: TObject);
    procedure Image2Click(Sender: TObject);
    procedure sTrackBar1Change(Sender: TObject);
    procedure Image5Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    function GetApplicationDirectory: string;
  end;

var
  Form1: TForm1;
  DATFILE: array[1..100] of string;
  I, C:integer;


implementation


{$R *.dfm}


function TForm1.GetApplicationDirectory: string;
begin
  Result := ExtractFilePath(ParamStr(0)) + 'Easy Start Loader.exe';
end;

procedure TForm1.Image2Click(Sender: TObject);
var sl: TStringlist;
    J,K:integer;
    regist, auto: TRegistry;
    PLACED,PLACE:string;
begin
  // BATCH DATEI GETT GESCHRIWWEN
  sl := TStringlist.Create;
  try
    sl.Add('@echo off');
    for J:=1 to C do
    begin
      sl.Add('start ' + chr(34) + chr(34) + ' ' + chr(34) + DATFILE[J] + chr(34));
    end;
    sl.SaveToFile('C:\EasyStartTimer.bat');
  finally
    sl.Free;
  end;
  // ------------------------------------------

  // REGISTRY WERT GETT GESCHRIWWEN
  regist:=TRegistry.Create;
  try
    regist.RootKey:=HKEY_CURRENT_USER;
    regist.OpenKey('Software\Easy Start Timer\StartTime', true);
    regist.WriteInteger('Time',round(Form1.sTrackBar1.Position));
  finally
    regist.free;
  end;
  // ------------------------------------------

  // LOADER GETT KOPEIERT
  PLACED:=GetApplicationDirectory;
  PLACE:= 'C:\Easy Start Loader.exe';
  copyfile(PChar(PLACED),PChar(PLACE),false);
  // ------------------------------------------

  // Loader gett an den autostart gesaat.
  auto:=TRegistry.Create;
  try
    auto.RootKey:=HKEY_LOCAL_MACHINE;
    auto.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', true);
    auto.writestring('Easy Start Loader','C:\Easy Start Loader.exe');
  finally
    auto.free;
  end;
  // ------------------------------------------
  
  for K:=1 to C do
  begin
    DATFILE[K]:='';
  end;
  Form1.sMemo1.Text:= Form1.sMemo1.Text + 'Activated ! Look Log for more Details.' + #13#10;
end;

procedure TForm1.Image4Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
    sPanel1.caption := OpenDialog1.Filename;
end;

procedure TForm1.Image3Click(Sender: TObject);
var TMP:string;
begin
  if (Form1.sPanel1.Caption <> '') and (Form1.sPanel1.Caption <> TMP) then
  begin
    TMP:=Form1.sPanel1.Caption;
    Form1.sMemo1.Text:= Form1.sMemo1.Text + Form1.sPanel1.Caption + #13#10;
    DATFILE[I]:=Form1.sPanel1.Caption;
    inc(C);
    inc(I);
  end;
end;

procedure TForm1.sTrackBar1Change(Sender: TObject);
begin
  Form1.Label1.Caption:=FloatToStr(Form1.sTrackBar1.Position);
end;

procedure TForm1.Image5Click(Sender: TObject);
var regist, auto, key: TRegistry;
    J:integer;
begin
  // Registry Werter gin gelöscht
  regist:=TRegistry.Create;
  try
    regist.RootKey:=HKEY_CURRENT_USER;
    regist.OpenKey('Software\Easy Start Timer\StartTime', true);
    regist.DeleteValue('Time');
  finally
    regist.free;
  end;

  key:=TRegistry.Create;
  try
    key.RootKey:=HKEY_CURRENT_USER;
    key.OpenKey('Software', true);
    key.DeleteKey('Easy Start Timer\Starttime');
    key.DeleteKey('Easy Start Timer');
  finally
    key.free;
  end;

  auto:=TRegistry.Create;
  try
    auto.RootKey:=HKEY_LOCAL_MACHINE;
    auto.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', true);
    auto.DeleteValue('Easy Start Loader');
  finally
    auto.free;
  end;

  // Dateien gin gelöscht.
  Deletefile('C:\EasyStartTimer.bat');
  Deletefile('C:\Easy Start Loader.exe');
  for J:=1 to C do
  begin
    DATFILE[J]:='';
  end;
  C:=0;
  Form1.sMemo1.Text:= Form1.sMemo1.Text + 'Deactivated ! Look Log for more Details.' + #13#10;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  I:=1;
  C:=0;
end;



end.
  Mit Zitat antworten Zitat