Autor Beitrag
Maisinator
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167

Win XP HE SP3, Win Vista HP SP2
Delphi ;-)
BeitragVerfasst: Do 14.05.09 16:36 
hi, ich möchte ein prog schreiben, mit dem man autorun.inf 's erstellen kann.

hier mein text:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
procedure TForm1.Button1Click(Sender: TObject);
var x, Pfad: string;
    MyFile: TStringList;
begin
if Edit1.Text = 'Bitte Autorun-Datei eingeben' then
  Form4.ShowModal
else
  begin
   x:= Edit1.Text;
   Memo1.Lines.Add('[autorun]' + #13#10 + 'open = ' + x);
   Pfad:= 'C:\Autorun.inf';
   MyFile := TStringList.Create;
   try
     MyFile.Clear;
     MyFile.Add(Memo1.Text);
     MyFile.SaveToFile(Pfad);
   finally
   MyFile.Clear;
   MyFile.Destroy;
   end;
   Form3.ShowModal;
  Edit1.ReadOnly:= true;
   Edit1.Enabled:= false;
   Neu1.Visible:= true;
   Button1.Enabled:= false;
  end;
end;


nun meine frage: wenn ich eine zweite autorun.inf erstellen möchte, soll die erste überschrieben werden. leider wird die neue "autorun.inf" einfach zu der alten dann hineingeschrieben??? erst wenn ich das prog schließe und neu kompiliere wird die autorun.inf wieder überschrieben... kann mir jemand helfen???
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Do 14.05.09 16:39 
Hallo!

Schau dir mal Suche in der Entwickler-Ecke DELETEFILE(); an :)

Lösch sie doch einfach vorher.

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 14.05.09 16:40 
Wenn du das speicherst, wird die alte auch überschrieben. Du kannst aber auch gleich schreiben Memo1.Lines.SaveToFile...
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 14.05.09 16:49 
Und statt MyFile.Destroy solltest Du MyFile.Free benutzen.
Nico72
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50

Win XP, Vista
Delphi 7, Delphi 2006
BeitragVerfasst: Do 14.05.09 16:52 
user profile iconMaisinator hat folgendes geschrieben Zum zitierten Posting springen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.Button1Click(Sender: TObject);
var x, Pfad: string;
    MyFile: TStringList;
begin
if Edit1.Text = 'Bitte Autorun-Datei eingeben' then
  Form4.ShowModal
else
  begin
   x:= Edit1.Text;
   Memo1.Lines.Add('[autorun]' + #13#10 + 'open = ' + x);
   Pfad:= 'C:\Autorun.inf';
   MyFile := TStringList.Create;
   try
     MyFile.Clear;
     MyFile.Add(Memo1.Text);
...


Du fügst die Zeilen ja auch hinten an den Text im Memo an, und speicherst es dann komplett.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 14.05.09 18:49 
Wobei mir auffällt: Du hast ein Editfeld, in dem der Inhalt drin ist, und dann noch ein Memo?!?

Wozu hat der Benutzer zwei Eingabefelder? :shock:
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Do 14.05.09 20:07 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Wobei mir auffällt: Du hast ein Editfeld, in dem der Inhalt drin ist, und dann noch ein Memo?!?

Wo siehst du das? Ich seh nur ein Edit Feld, wo der Benutzer einen Dateinamen eingibt, der automatisch gestartet werden soll, und ein Memo, wo der Inhalt der Autorun.inf drin steht.

_________________
PROGRAMMER: A device for converting coffee into software.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 14.05.09 20:35 
Ok, ganz klar war das daraus nicht, aber das Memo war wie ich vermutet hatte unsichtbar wie ich mittlerweile sicher weiß (PN). ;-)

Deshalb hier nochmal richtig:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
procedure TForm1.Button1Click(Sender: TObject);
var
  Pfad: string;
  MyFile: TStringList;
begin
  if Edit1.Text = 'Bitte Autorun-Datei eingeben' then
    Form4.ShowModal
  else
  begin
    Pfad:= 'C:\Autorun.inf';
    MyFile := TStringList.Create;
    try
      MyFile.Text := '[autorun]'#13#10'open = ' + Edit1.Text);
      MyFile.SaveToFile(Pfad);
    finally
      MyFile.Free;
    end;
    Form3.ShowModal;
    Edit1.ReadOnly := true;
    Edit1.Enabled := false;
    Neu1.Visible := true;
    Button1.Enabled := false;
  end;
end;
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 15.05.09 13:04 
Das könnte man aber auch mit TIniFile machen, da der Aufbau ja der gleiche ist.