Autor Beitrag
Fabian E.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 554

Windows 7 Ultimate
Visual Studio 2008 Pro, Visual Studion 2010 Ultimate
BeitragVerfasst: Mo 08.10.07 10:28 
hallo!

ich habe folgende konfiguration:

ordner1 -------- ordner2

beide ordner liegen in ordner 3

wie kann ich jetzt mit einer exe in ordner 2 eine exe in odner 1 öffnen?

ich denke mal irgendetwas mit ExtractFilePath(ParamStr(0)) aber ich weiß nicht so genau wie ich 'ordner2' dann aus dem string löschen soll.

vielen dank

gruß


Moderiert von user profile iconNarses: Topic aus Windows API verschoben am Mo 08.10.2007 um 10:33
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 08.10.07 10:34 
Moin!

Spontan fällt mir da folgender Ansatz ein: Nimm z.B. diese Suche in: Delphi-Forum, Delphi-Library EXPLODE-Funktion und als Trennzeichen '\', dann hast du den Pfad zerlegt und kannst ihn deinen Wünschen entsprechend neu zusammenstellen. :idea: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Fabian E. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 554

Windows 7 Ultimate
Visual Studio 2008 Pro, Visual Studion 2010 Ultimate
BeitragVerfasst: Mo 08.10.07 10:46 
hm...wäre es nicht vllt möglich in dem verzeichnis string das letzte "/" zu suchen und von da aus dann zu löschen?
aber wie sag ich dem compiler, dass ich den index vom letzten "/" will und nicht z.b. vom ersten?

gruß
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Mo 08.10.07 10:51 
Nicht besonders schön die Funktion aber sie sollte funktionieren:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
function LastPos (SubStr: String; S: String): Integer;
begin
   result := Pos(Reverse(SubStr), Reverse(S)) ;

   if (result <> 0then
     result := ((Length(S) - Length(SubStr)) + 1) - result + 1;
end;


Lg, Martin

_________________
Ein Nutzer der Ecke ;-)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 08.10.07 10:56 
Moin!

Gab´s nicht sowas wie LastDelimiter? :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 08.10.07 11:29 
Ja, sowas gibts.
Wenn man einen Pfad hat, kann man so den übergeordneten Ordner bestimmen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
//Sicherstellen, dass am Ende kein "\" steht
pfad := ExcludeTrailingPathDelimiter(pfad);
// letztes "\" bestimmen und kopieren
pfad := Copy(pfad,1,LastDelimiter('\',pfad));

_________________
We are, we were and will not be.
Fabian E. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 554

Windows 7 Ultimate
Visual Studio 2008 Pro, Visual Studion 2010 Ultimate
BeitragVerfasst: Mo 08.10.07 11:30 
okay vielen dank! :)
ich hab es jetzt so gelöst(nicht schön, aber selten ;) )
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm3.Button3Click(Sender: TObject);

Var Index: Integer;
    Dir: String;
begin
Dir := ExtractFilePath(ParamStr(0));
Index := LastDelimiter('\',Dir)-7;
Delete(dir,Index,7);
Dir := Dir+'Server\Server.exe';
ShellExecute(handle,'open',PChar(dir),nil,nil,SW_Show);


das problem war, das mein String am Ende noch ein "\" hat, dass heißt ich brauchte das vorletzte "\"
Dies habe ich dann durch das "-7" gelöst, da mein verzeichnis name dort fest ist! ;)

gruß

EDIT: ne gä?! :D das kommt leider etwas spät, aber ich werde es wohl mal testen! danke! :)
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 08.10.07 12:07 
Hallo,

ExtractFilePath kommt auch mit Ordnern klar:

ausblenden Delphi-Quelltext
1:
s := ExtractFilePath('c:\temp\xxx'); // s = 'c:\temp\					

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 08.10.07 12:20 
sowas gabs letztens bei Delphi.About.Com
-> delphi.about.com/od/...qt/parent_folder.htm

_________________
In the beginning was the word.
And the word was content-type: text/plain.
MKX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 95

Win XP, Ubuntu Linux 7.02
Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Mo 08.10.07 12:47 
Hmm. Geht denn das nicht?:
ausblenden Delphi-Quelltext
1:
ShellExecute(handle,'open',PChar(ExtractFilePath(Application.Exename)+'..\Server\Server.exe'),nil,nil,SW_Show);					

Es kann sein, dass ich mich total irre, aber das müsste so doch gehen, oder?

_________________
Für das Falsche gibt es keine Grenze und der Irrtum ist grenzenlos. (Seneca)
Fabian E. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 554

Windows 7 Ultimate
Visual Studio 2008 Pro, Visual Studion 2010 Ultimate
BeitragVerfasst: Mo 08.10.07 13:11 
nein, denn Application.ExeName liefert das Verzeichnis der .exe plus den namen der .exe!
mein problem war aber, das ich ein oberverzeichnis brauchte, also z.B.: client.exe liegt hier: C:\Dokumente und Einstellungen\La Passion\Desktop\TD-Multiplayer\Client, dann wollte ich das hier haben: C:\Dokumente und Einstellungen\La Passion\Desktop\TD-Multiplayer

siehst du den unterschied?

gruß
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Di 09.10.07 10:47 
user profile iconMKX hat folgendes geschrieben:
Hmm. Geht denn das nicht?:
ausblenden Delphi-Quelltext
1:
ShellExecute(handle,'open',PChar(ExtractFilePath(Application.Exename)+'..\Server\Server.exe'),nil,nil,SW_Show);					


user profile iconFabian E. hat folgendes geschrieben:
nein, denn Application.ExeName liefert das Verzeichnis der .exe plus den namen der .exe!


Deswegen ja das ExtractFilePath(...) , das gibt nur den Pfad zurück! ;-)

_________________
Anonymes Eckenkind