Autor Beitrag
Kuyatzu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Fr 21.09.07 22:56 
Hi Leute

Ich weiß nicht wie ich das hinbekomme das überprüft wird ob ShellExecute das Programm gestartet hat
und bei true/bzw. false eine andere Option folgt.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 21.09.07 23:03 
Wie jede API sollte Dir Suche im MSDN SHELLEXECUTE entweder True\False als Result liefern, ODER den Status über Suche im MSDN GETLASTERROR zurückmelden.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
bms
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 735

Win XP
Delphi 3, Delphi 6 PE, Delphi 2005 PE
BeitragVerfasst: Sa 22.09.07 01:20 
user profile iconBenBE hat folgendes geschrieben:
Wie jede API sollte Dir Suche im MSDN SHELLEXECUTE entweder True\False als Result liefern, ODER den Status über Suche im MSDN GETLASTERROR zurückmelden.


ShelleExecute gibt dir zwar ein Wert zurück, und, falls es <= 32 ist, dann ist es ein Fehlercode, aber kein Wert <= 32 bedeutet nicht automatisch, daß das Programm erfolgreich gestartet wurde. Allerdings ist Wert <= 32 auf jeden Fall ein Zeichen dafür, daß es nicht geklappt hat.

_________________
VORSICHT: Ich behersche seit heute die Fünf-Finger-Handflächen-Herz-Explodier-Schlag-Kampf-Technik >:(
Kuyatzu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Sa 22.09.07 08:30 
Danke :wink: :wink: :wink:
Das ist schon sehr hilfreich und danke für die schnelle Antwort.
Hab aber doch noch ein Problem und zwar weiß ich nicht wie man das den macht mit
result usw.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(0, 'open','yxz.exe', nil, nil,  SW_SHOW);
//hir muss ja der "result" hin weiß aber nicht wie man das macht
//das wenn ShellExecute nicht geklapt hat
//das den ShowMessage gezeigt wird
ShowMessage('"yxz.exe" nicht gefunden.Bitte überprüfen sie den Pfad');
end;
Timosch
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1314

Debian Squeeze, Win 7 Prof.
D7 Pers
BeitragVerfasst: Sa 22.09.07 10:35 
Ähm, ShellExecute ist eine Funktion. Also:
ausblenden Delphi-Quelltext
1:
a:=ShellExecute(...);					

Und in a ist dann der Result-Wert von ShellExecute.

_________________
If liberty means anything at all, it means the right to tell people what they do not want to hear. - George Orwell
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Sa 22.09.07 10:47 
Moin!

Wie wäre es denn, wenn du erstmal separat überprüfst, ob die Anwendung existiert? Dann kannst du diesen Fall schonmal ausschließen und ganz sicher sein: :idea:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if FileExists('yxz.exe') then begin
    if (ShellExecute(0, 'open', 'yxz.exe', nil, nil,  SW_SHOW) <= 32) then
      ShowMessage('Fehler beim Start von "yxz.exe"!');
  end
  else
    ShowMessage('"yxz.exe" nicht gefunden. Bitte überprüfen sie den Pfad');
end;

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Sa 22.09.07 10:55 
Hallo Narses, dass ist unnötiger Aufwand. Wenn ShellExecute es nicht findet, dann gibt das einen entsprechenden Fehlercode zurück (siehe MSDN-link).
Kuyatzu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Sa 22.09.07 13:25 
danke das ist gut damit ist das Problem gelöst.
habt ihr auch eine zweite oder dritte Meinung zu meinem anderen Problem ??

www.delphi-forum.de/viewtopic.php?t=76581