/ Forside / Teknologi / Udvikling / Delphi/Pascal / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
Delphi/Pascal
#NavnPoint
oldwiking 603
jrossing 525
rpje 520
EXTERMINA.. 500
gandalf 460
gubi 270
DJ_Puden 250
PARKENSS 230
technet 210
10  jdjespers.. 200
ShellExecute
Fra : Carsten


Dato : 04-10-05 13:24

Når man bruger ShellExecute (Starter et eksternt program) så returneres
der fra kaldet med det samme, er det muligt at få kaldet til at vente
til det eksterne program lukkes.

Carsten

 
 
Michael Thomsen (05-10-2005)
Kommentar
Fra : Michael Thomsen


Dato : 05-10-05 09:46

On Tue, 04 Oct 2005 14:23:39 +0200, Carsten <mail@no-mail.dk> wrote:

> Når man bruger ShellExecute (Starter et eksternt program) så returneres
> der fra kaldet med det samme, er det muligt at få kaldet til at vente
> til det eksterne program lukkes.

Nej; men du kan bruge ShellExecuteEx - se fx her:
http://www.festra.com/eng/mtut01.htm

(google "shellexecute wait for termination")

//michael

--
Instead of email, use this: http://mtech.dk/thomsen/contact.php

PØLLE (23-10-2005)
Kommentar
Fra : PØLLE


Dato : 23-10-05 09:49

Hej Carsten

Værs'go

Function PFURunExecutable(FileName :String; Visibility: integer;
TimeOut:LongWord): DWORD;
var MsgWaitForMultipleObjects_TimeOut:LongWord;

Procedure WaitFor( processHandle: THandle );
Var
ret: DWORD;
Begin
MsgWaitForMultipleObjects_TimeOut:=TimeOut;
Repeat
ret := MsgWaitForMultipleObjects(
1, { 1 handle to wait on }
processHandle, { the handle }
False, { wake on any event }
MsgWaitForMultipleObjects_TimeOut,
// TimeOut,
// INFINITE, { wait without timeout }
QS_PAINT or { wake on paint messages }
QS_SENDMESSAGE { or messages from other threads }
);
If ret = WAIT_FAILED Then Exit; { can do little here }
If ret = (WAIT_OBJECT_0 + 1) Then Begin
{ Woke on a message, process paint messages only. Calling
PeekMessage gets messages send from other threads processed.
}
{ While PeekMessage( msg, 0, WM_PAINT, WM_PAINT, PM_REMOVE ) Do
DispatchMessage( msg );}
End;
Until ret = WAIT_OBJECT_0;
End; { Waitfor }
Var { V1 by Pat Ritchey, V2 by P.Below }
zAppName:array[0..512] of char;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
Begin { WinExecAndWait32V2 }
StrPCopy(zAppName,FileName);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
// StartupInfo.dwFlags :=STARTF_USESTDHANDLES;
StartupInfo.wShowWindow := Visibility;
If not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) { pointer to PROCESS_INF }
Then
Result := DWORD(-1) { failed, GetLastError has error code }
Else Begin
// WaitForSingleObject(ProcessInfo.hProcess, TimeOut);
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
Waitfor(ProcessInfo.hProcess);
GetExitCodeProcess(ProcessInfo.hProcess, Result);
CloseHandle( ProcessInfo.hProcess );
CloseHandle( ProcessInfo.hThread );
End; { Else }
End; { WinExecAndWait32V2 }





Søg
Reklame
Statistik
Spørgsmål : 177549
Tips : 31968
Nyheder : 719565
Indlæg : 6408820
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste