Run another application from yours
Using WinExec :
WinExec ( PChar ( 'notepad.exe' ) , SW_SHOWNORMAL ) ;
or
WinExec ( PChar ( 'c:\windows\notepad.exe' ) , SW_SHOWNORMAL ) ;
Using WinExecAndWait :
Function WinExecAndWait ( FileName : String ; Visibility :
integer ) : integer ;
Var
AppName : Array[ 0..512 ] Of char ;
CurDir : Array[ 0..255
] Of char ;
WorkingDir : String ;
StartupInfo
: TStartupInfo ;
ProcessInfo
: TProcessInformation ;
Resultat :
DWord ;
Begin
StrPCopy (
AppName , FileName ) ;
GetDir ( 0 ,
WorkingDir ) ;
StrPCopy (
CurDir , WorkingDir ) ;
FillChar (
StartupInfo , Sizeof ( StartupInfo ) , #0 ) ;
StartupInfo.cb := Sizeof ( StartupInfo ) ;
StartupInfo.dwFlags := STARTF_USESHOWWINDOW ;
StartupInfo.wShowWindow
:= Visibility ;
CreateProcess ( Nil , AppName , Nil , Nil , false , CREATE_NEW_CONSOLE
Or
NORMAL_PRIORITY_CLASS , Nil , Nil , StartupInfo , ProcessInfo ) ;
Repeat
exitCode := WaitForSingleObject ( ProcessInfo.hProcess , 1000 ) ;
Application.ProcessMessages ;
Until (
exitCode <> WAIT_TIMEOUT ) ;
GetExitCodeProcess ( ProcessInfo.hProcess , Resultat ) ;
MessageBeep
( 0 ) ;
CloseHandle
( ProcessInfo.hProcess ) ;
Result :=
Resultat ;
End ;