Autor Beitrag
Ice
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Do 13.03.03 16:43 
Hallo Leute,

kann man ,und wenn ja wie, zur Laufzeit den Pfad in dem sich eine Datei befindet ermitteln? Geht das mit GetFilePath?

Vielen Dank im voraus,
mfg
Ice
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Do 13.03.03 16:57 
Also du kannst jederzeit mit GetFilePath den Pfad von einer Datei ermitteln. Beispielsweise mit
ausblenden Quelltext
1:
aString := GetFilePath(ParamStr(0));					

den Pfad ermitteln, in dem sich dein Programm befindet.
Statt ParamStr(0) kannst du natürlich jede andere Datei einsetzen.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: Do 13.03.03 17:03 
GetFilePath ist ein Api Exot der nur von höheren Delphi Versionen akzeptiert wird.

Alternativ geht auch

ausblenden Quelltext
1:
aString := ExtractFilePath(ParamStr(0)); // mit einem "\" am Ende					


oder

ausblenden Quelltext
1:
aString := ExtractFileDir(ParamStr(0)); // ohne einem "\" am Ende					

_________________
Popov
Ice Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Do 13.03.03 17:07 
:) Ales klar! Vielen Dank für die Schnellen Antworten aber was hat es mit dem ParamStr(0) auf sich?

mfg
Ice
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Do 13.03.03 17:30 
Damit kannst Du verschiedene Parameter, die an Dein Programm übergeben werden abfragen. Der mit Index 0 ist ein Sonderfall, weil er den absoluten Pfad zum Programm darstellt. 1 ist dann der erste Parameter, mit dem das Prog ausgeführt wurde, 2 der zweite usw.

Gruß
Ice Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Fr 14.03.03 08:59 
:) Vielen Dank!
mfg
Ice
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Fr 14.03.03 10:09 
In der FAQ befindet sich auch über das Thema Parameter ein Beitrag: ...die übergebenen Parameter auslesen?

Gruß
TINO