The following set of API functions do the job:
DECLARE INTEGER CreateProcess IN kernel32;
STRING lpAppName, STRING lpCmdLine, INTEGER lpProcAttr,;
INTEGER lpThrAttr, INTEGER bInhHandles, INTEGER dwCrFlags,;
INTEGER @ lpEnvir, STRING lpCurDir, STRING lpStInfo,;
STRING @ lpProcInfo
DECLARE INTEGER CloseHandle IN kernel32 INTEGER hObject
DECLARE INTEGER WaitForSingleObject IN kernel32;
INTEGER hHandle, INTEGER dwMilliseconds
* * *
First the CreateFunction is used to create a process, the lpCmdLine parameter is something like
C:\program files\Microsoft Office\Office10\excel.exe
Then, after a valid process handle returned, the WaitForSingleObject is used with this handle and INFINITE parameter to catch the moment when the process is terminated.
And finally -- the CloseHandle is used to delete the process handle.
* * *
More information on API calls:
http://www.news2news.com/vfp