global define include "WINDEF.INC" include "WINNT.INC" include "WINBASE.INC" include "ERRNO.INC" end integer function SYSTEM(string) implicit none character*(*) string record/STARTUPINFO/si record/PROCESS_INFORMATION/pi integer iret integer dw integer dwExitCode dwExitCode = -1 si.cb = 68 ! sizeof(si) si.lpReserved = 0 si.lpDesktop = 0 si.lpTitle = 0 si.dwFlags = 0 si.cbReserved2 = 0 si.lpReserved2 = 0 ! VAL(LOC inhibits pushing string length on the stack iret = CreateProcess( & VAL4(0), & VAL(LOC(trim(string)//char(0))), & VAL4(0), & VAL4(0), & VAL4(TRUE), & VAL4(NORMAL_PRIORITY_CLASS), & VAL4(0), & VAL4(0), & si, & pi) if (iret .NE. 0) then dw = WaitForSingleObject(VAL(pi.hProcess),VAL(INFINITE)) if (dw .NE. -1) then call GetExitCodeProcess(VAL(pi.hProcess),dwExitCode) end if call CloseHandle(VAL(pi.hThread)) call CloseHandle(VAL(pi.hProcess)) end if c write (*,*) 'inside SYSTEM: ' SYSTEM = dwExitCode; end