Autor Beitrag
Rawku5
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Do 13.11.03 15:10 
Hi!

Ich versuche schon die ganze Zeit ein externes programm unsichtbar zu starten.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
ShellExecute(0,
               Nil,
               PChar(Pfad),
               Pchar('-Parameter'),
               Pchar('C:\StartDir'),
               SW_HIDE);

Startet das Programm normal sichtbar, dann hab ich drunter folgendes gehängt:
ausblenden Delphi-Quelltext
1:
2:
3:
sleep(1000);
hwnd:= FindWindow(nil'Microsoft Internet Explorer');
ShowWindow(hwnd, SW_HIDE);

Ok, das Programm wird zwar unsichtbar aber man sieht es kurz wegen dem sleep, wenn ich das sleep aber nun wegmache kommt es oft vor, dass es zu schnell geht und das Programm garnicht unsichtbar wird!

Wisst ihr wie ich ein externes prog. direkt unsichtbar öffne. Also es soll sich von Anfang an unsichtbar öffnen nicht dass man später SW_HIDE machen muss...?

Danke für Antworten!

MfG,
Rawku5.

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 13.11.03 15:39 
Mit Suche in: Delphi-Forum, Delphi-Library CREATEPROCESS oder Suche in: Delphi-Forum, Delphi-Library SHELLEXECUTEEX starten, dann hast du das Process-Handle und kannst dann mit Suche in: Delphi-Forum, Delphi-Library WAITFORINPUTIDLE warten bis der Prozess fertig initialisiert ist...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Rawku5 Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: So 16.11.03 16:00 
Konkretes Beispiel?
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 16.11.03 17:39 
Wenn du den Suchlinks nachgegangen wärst wärst du unter anderem auf dieses Code-Schnipsel gestoßen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
function Starte(appname: string): boolean;
var StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  FillChar(StartupInfo, SizeOf(TStartupInfo),0);
  StartupInfo.cb:=SizeOf(TStartupInfo);
  if CreateProcess(nil, PChar(appname), nilnil, false,
  NORMAL_PRIORITY_CLASS, nilnil, startupinfo, ProcessInfo) then
  begin
    try
      waitforinputidle(processinfo.hProcess, INFINITE);
    finally
      CloseHandle(ProcessInfo.hProcess);
      CloseHandle(ProcessInfo.hThread);
    end;
    result:=true;
  end
  else
    result:=false;
end;
( www.delphi-forum.de/...ght=waitforinputidle )

Das dürfte sich eigentlich sehr leicht an deine Bedürfnisse anzupassen sein...!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!