Autor Beitrag
icedre
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Windows XP Prof. , SuSE Linux 9.0 Prof.
Borland Delphi 6.0 Enterprise
BeitragVerfasst: So 24.04.05 14:11 
Hallo,

ich hab da ein Problem:
und zwar möchte ich ein Programm mit Shellexecute starten, der Code dafür ist folgender:
ausblenden Delphi-Quelltext
1:
ShellExecute(Application.Handle, 'open''C:\WINDOWS\explorer.exe''-s -t 2'nil, SW_SHOW);					


Anstatt der genauen Pfadangabe "C:\WINDOWS\explorer.exe" , möchte ich an der Stelle einen String angeben, in dem der Pfad zum Programm steht.
Wie kann ich jetzt den String dort mit einbringen ?
So:
ausblenden Delphi-Quelltext
1:
ShellExecute(Application.Handle, 'open', pfad_string, '-s -t 2'nil, SW_SHOW);					

funktioniert es jedenfalls nicht... :cry:

Vielen Dank, icedre

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
Moderiert von user profile iconChristian S.: Topic aus VCL (Visual Component Library) verschoben am So 24.04.2005 um 14:13

_________________
Sprach Abraham zu Braham:
Kann ich deine Frau besamen
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: So 24.04.05 14:14 
wo wird denn pfad_string inizalisiert??

versuch es mal so

ausblenden Delphi-Quelltext
1:
 ShellExecute(Application.Handle, 'open''explorer.exe''c:\winnt'nil, SW_SHOW);					

die pfadangabe mut du extra setzten und für was die parameter welche du angegeben hast??

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 24.04.05 14:42 
Wenn ich das richtig in Erinnerung habe, werden bei Shellexecute PChars erwartet, also muss man ggf. ein Typecast durchführen:
ausblenden Delphi-Quelltext
1:
ShellExecute(Application.Handle, 'open'PChar(pfad_string)'-s -t 2'nil, SW_SHOW);					

_________________
We are, we were and will not be.
icedre Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Windows XP Prof. , SuSE Linux 9.0 Prof.
Borland Delphi 6.0 Enterprise
BeitragVerfasst: So 24.04.05 14:49 
Hallo,

danke.

Wenn ich es mit PCChars mache öffnet er mir immer das ein und selbe Verzeichnis, egal, was im String steht.
C:\Programme\Borland\Delphi6\Projects

_________________
Sprach Abraham zu Braham:
Kann ich deine Frau besamen
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: So 24.04.05 14:50 
user profile iconicedre hat folgendes geschrieben:
Anstatt der genauen Pfadangabe "C:\WINDOWS\explorer.exe" , möchte ich an der Stelle einen String angeben, in dem der Pfad zum Programm steht.
Wie kann ich jetzt den String dort mit einbringen ?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
  strApp: String;
  strParam: String;
begin

  strApp := 'C:\WINDOWS\SYSTEM32\NOTEPAD.EXE';
  strParam := 'C:\BOOT.INI';
  ShellExecute(GetDesktopWindow, 'open', PChar(strApp), PChar(strParam), nil, SW_SHOWNORMAL);

end;

_________________
Ciao, Sprint.
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 24.04.05 15:15 
Kann es sein das es was ShellExecute 'Tausende' verschiedene Möglichkeiten gibt?
Ich hab jetzt schon mindestens 5 verschiedene Möglichkeiten gesehn. Ist doch klar dass es da zun Problemen kommen kann.
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 24.04.05 15:24 
user profile iconFabian W. hat folgendes geschrieben:
Kann es sein das es was ShellExecute 'Tausende' verschiedene Möglichkeiten gibt?

Nein! Es gibt nur den einen Befehl, und dessen Parameter sind auch fest vorgegeben. Wenn du mal davon ausgehst, dass der Aufruf eines Programms, einer Webseite oder einer Email-Adresse letztlich alle das gleiche Ziel haben (das Programm zu öffnen, die Webseite anzuzeigen, ein Email-Fenster zu öffnen), und wenn du alle ohnehin falschen Beispiele vergisst (nach dem Motto: "Ich habe ShellExecute so aufgerufen, aber es klappt nicht" :lol:), dann bleibt nur eine Möglichkeit übrig. ;)
icedre Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Windows XP Prof. , SuSE Linux 9.0 Prof.
Borland Delphi 6.0 Enterprise
BeitragVerfasst: So 24.04.05 15:56 
So,

alles klar, es funktioniert:
ausblenden Delphi-Quelltext
1:
2:
sollprog:='C:\WINDOWS\explorer.exe';
ShellExecute(Application.Handle, 'open', PChar(sollprog), nilnil, SW_SHOW);


Vielen Dank :)

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.

_________________
Sprach Abraham zu Braham:
Kann ich deine Frau besamen