Autor Beitrag
Hatebreeder
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
D7 Corp
BeitragVerfasst: Mo 18.11.02 16:25 
also ich hab folgendes vor: 2 buttons, auf einem wählt man das verzeichnis das fürs prog benötigt wird (soll inis editieren)
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.BtDefineClick(Sender: TObject);
var dir: string;
begin
  if SelectDirectory('Wählen Sie ein Verzeichnis!', '', dir) then
   LbPath.caption:=dir;
end;

auf dem zweiten button soll dann in diesem verzeichnis die datei bla.ini geöffnet werden...ich habe das hier versucht aber es klappt nicht:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.BtOpenClick(Sender: TObject);
var Path: string;
begin
Path:=LbPath.caption + '\bla.ini';
ShellExecute(Handle, 'open', 'Path', nil, nil, SW_SHOWNORMAL);
end;

er kann die datei nicht öffnen, da er nach der dati 'Path' sucht...die '' kann ich nicht entfernen, da es in ShellExecute so festgelegt ist...

Hoffe ihr versteht mein Problem habs eilig darum schreib ich bisserl unverständlich ^^

greetz
Der Michel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 38



BeitragVerfasst: Mo 18.11.02 16:35 
Hallo,

hmm... also wenn ich dich richtig verstehe müßte das hier
ausblenden Quelltext
1:
ShellExecute(Handle, 'open',PChar(Path), nil, nil, SW_SHOWNORMAL);					

eigentlich die Lösung sein. ;-)

Gruß,
Michel
JeanvanHees
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Mo 18.11.02 17:23 
Schau mal in den FAQ für die textdatei zu öffnen.
Ist übrigens die Opendialog component nicht ein schöneres alternativ für das selectieren des files?

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!
Hatebreeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
D7 Corp
BeitragVerfasst: Mo 18.11.02 18:33 
super, danke michael das war die lösung !
@jeanvanhees mit opendialog ist nicht gut, weil er eben veschiedene files aus einem folder öffnen soll...
Hatebreeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
D7 Corp
BeitragVerfasst: Mo 18.11.02 20:54 
ganz dumme frage:
kann ich den path irgendwie speicher?also ich wollte mal wissen wie ^^

thx
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 18.11.02 21:16 
Wie speichern? Temporär im Programm oder in einer Datei auf der Festplatte?
Hatebreeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
D7 Corp
BeitragVerfasst: Mo 18.11.02 21:34 
in einer externen datei auf der platte...zb settings.txt oder so
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 18.11.02 21:36 
Informier dich mal hier im Forum und in der Hilfe über TInifile.
Palmetshofer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44



BeitragVerfasst: Mo 18.11.02 21:56 
Um zu Speichern:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.BtnSaveClick(Sender:TObject);
var
List: TStrings;
dir: String;
begin
if SelectDirectory('Wählen Sie ein Verzeichnis!', '', dir) then 
   LbPath.caption:=dir;
List := TstringList.Create;
List.Add(dir + '\bla.ini');
List.SaveToFile('C:\Windows\ProgrammSettings.txt');
end;



Um zu Laden:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.BtnSaveClick(Sender:TObject);
var
List: TStrings;
dir: String;
begin
List.LoadFromFile('C:\Windows\ProgrammSettings.txt');
dir := List.Strings[0];
ShellExecute(Handle, 'open', PChar(dir), nil, nil, SW_SHOWNORMAL);
end;


Ich hoffe ich hab mich net verschrieben! Ich schätze es wird auch einen anderen weg geben aber dir ist glaube ich net schlecht!
Du musst nur schaun dass beim neuen speichern eventuell die Stinglist 'gecleart' wird sonst stimmt der Index Integer nicht!

MfG Matthias

_________________
Menschen stolpern nicht über Berge, sondern über Maulwurfshügel.
Konfuzius
Hatebreeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
D7 Corp
BeitragVerfasst: Mo 18.11.02 21:56 
ok super thx, hat mir seh geholfen !
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 18.11.02 22:00 
Wo ist der Ressourcen-Schutz? :roll:
Hatebreeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
D7 Corp
BeitragVerfasst: Mo 18.11.02 22:04 
so hab ích das jetzt:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TLauncher.MiSaveClick(Sender: TObject);
begin{1}
ini := TIniFile.Create('C:\Dokumente und Einstellungen\Anthony\Desktop\Launcher\settings.ini');
try
  ini.WriteString('Settings','Path',Path);
finally
  ini.Free;
end;{1}
end;

procedure TLauncher.MiLoadClick(Sender: TObject);
begin{1}
ini := TIniFile.Create('C:\Dokumente und Einstellungen\Anthony\Desktop\Launcher\settings.ini');
try
  Path := ini.ReadString('Settings','Path','');
finally
  ini.Free;
end;{1}
end;
wie muss ich die zeile ini := TIniFile.Create('C:\Dokumente und Einstellungen\Anthony\Desktop\Launcher\settings.ini'); ändern, damit er statt dem ganzen pfad einfach das verzeichnis wo auch die exe drin is nimmt?

sorry 4 being stupid ^^
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 18.11.02 22:06 
ParamStr(0), ExtractFilepath.
Hatebreeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
D7 Corp
BeitragVerfasst: Mo 18.11.02 22:10 
kannste mir bidde ma die genaue zeile dann sagen? *duck*
thx nochma für deine geduld mit nem newbie ^^
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 18.11.02 22:35 
ParamStr(0) liefert dir den Pfad plus Anwendungsnamen und ExtractFilepath extrahiert dir den Pfad aus dieser Angabe. Dann mußt du nur noch deinen Dateinamen dranhängen.
Hatebreeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP
D7 Corp
BeitragVerfasst: Di 19.11.02 12:56 
ok funzt nu riesen thx nochma