Autor Beitrag
Markus254
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23

Winnt2000
d7 Prof
BeitragVerfasst: Di 03.05.05 19:45 
Hi
Ich versuche aus einer txt datei den Pfad eines Programmes herauszufiltern und zu starten.

Problem: Ich weiss nicht wie man das anstellt.
Der ganze pfad befindet sich in der 2 Zeile der txt datei.

Könnt ihr mir helfen ?
Danke schon im Vorraus
Markus254


Moderiert von user profile iconChristian S.: Topic aus Windows API verschoben am Di 03.05.2005 um 19:47
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 03.05.05 19:54 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
uses ... , shellapi;
...
procedure TForm1.Button1Click(Sender: TObject);
var sl:tstringlist;
begin
   sl:=tstringlist.create;
   sl.LoadFromFile('C:\myini.txt');
   shellexecute(handle,'open',pchar(sl.Strings[1]),nil,nil,sw_show);
   sl.Free;
end;

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Markus254 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23

Winnt2000
d7 Prof
BeitragVerfasst: Di 03.05.05 20:24 
Oh !
Danke funktioniert prima !!! :D
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 03.05.05 20:27 
aber nur solange die textdatei existiert und mindestens 2 zeilen hat...

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Markus254 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23

Winnt2000
d7 Prof
BeitragVerfasst: Di 03.05.05 21:51 
Und noch ne Frage :?: :
Wie kann ich machen das in der txt datei in der zeile 2 ein anderer pfad steht, also die Zeile löscht und dann einen anderen text in dieser Zeile steht, auch wenn es noch mehrere Zeilen hat (Habe da einen Tipp gekriegt der die ganze Datei löscht :( ) ?
Nochmal danke im Vorraus !
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 03.05.05 22:04 
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 sl:tstringlist;
    fn:string;
begin
   fn:='C:\myini.txt';
   if fileexists(fn) then begin
     sl:=tstringlist.create;
     sl.LoadFromFile(fn);
     if sl.Count > 1 then begin
    //   shellexecute(handle,'open',pchar(sl.Strings[1]),nil,nil,sw_show);
       sl.Strings[1]:='blubb.exe';
       sl.SaveToFile(fn);
     end;
     sl.Free;
   end;
end;

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...