>>>*======================================================================================== >>>* Executes another application, waits for it to complete and returns the error level >>>*======================================================================================== >>>LParameter tcCmdLine >>> >>> *-------------------------------------------------------------------------------------- >>> * API declarations >>> *-------------------------------------------------------------------------------------- >>> DECLARE INTEGER CreateProcess IN kernel32.DLL ; >>> String lpApplicationName, ; >>> STRING lpCommandLine, ; >>> INTEGER lpProcessAttributes, ; >>> INTEGER lpThreadAttributes, ; >>> INTEGER bInheritHandles, ; >>> INTEGER dwCreationFlags, ; >>> String lpEnvironment, ; >>> String lpCurrentDirectory, ; >>> STRING @lpStartupInfo, ; >>> STRING @lpProcessInformation >>> Declare long GetLastError in Win32API >>> >>> *-------------------------------------------------------------------------------------- >>> * Launch the application >>> *-------------------------------------------------------------------------------------- >>> Local lcStartupInfo, lcProcessInfo, lnOK >>> lcStartupInfo = ; >>> BINTOC(68,"RS") + ; >>> Replicate(Chr(0),40) + ; >>> BinToC(1,"RS") + ; >>> BinToC(0,"2RS") + ; && SW_HIDE >>> BinToC(0,"2RS") + ; >>> Replicate(Chr(0),16) >>> lcProcessInfo = Replicate(Chr(0),16) >>> lnOK = CreateProcess( ; >>> NULL, ; >>> m.tcCmdLine, ; >>> 0, ; >>> 0, ; >>> 1, ; >>> 0x20, ; >>> NULL, ; >>> NULL, ; >>> @lcStartupInfo, ; >>> @lcProcessInfo ; >>> ) >>> >>> *-------------------------------------------------------------------------------------- >>> * Extract the handles from the PROCESSINFO structure >>> *-------------------------------------------------------------------------------------- >>> Local lnProcessHandle, lnThreadHandle >>> If m.lnOK == 0 >>> Return -1 >>> Else >>> lnProcessHandle = CTOBIN(Substr(m.lcProcessInfo,1,4),"RS") >>> lnThreadHandle = CTOBIN(Substr(m.lcProcessInfo,5,4),"RS") >>> EndIf >>> >>> *-------------------------------------------------------------------------------------- >>> * Wait for the process to terminate >>> *-------------------------------------------------------------------------------------- >>> Declare Long WaitForSingleObject in Win32API Long, Long >>> WaitForSingleObject( m.lnProcessHandle, -1 ) >>> >>> *-------------------------------------------------------------------------------------- >>> * Get the error code >>> *-------------------------------------------------------------------------------------- >>> Local lnExitCode >>> lnExitCode = -1 >>> Declare Long GetExitCodeProcess in Win32API ; >>> Long hProcess, ; >>> Long @lpExitCode >>> GetExitCodeProcess( m.lnProcessHandle, @lnExitCode ) >>> >>> *-------------------------------------------------------------------------------------- >>> * Close handles >>> *-------------------------------------------------------------------------------------- >>> Declare CloseHandle in Win32API Long >>> CloseHandle( m.lnProcessHandle ) >>> CloseHandle( m.lnThreadHandle ) >>> >>>Return m.lnExitCode >>>