I use the procedure provided to me that will start the process, but I want the process to run in the background without a window appearing. Call
ExecProcess(ProgPath, '', False);
and function
function ExecProcess(ProgramName, WorkDir: string; Wait: boolean): integer; var StartInfo: TStartupInfo; ProcInfo: TProcessInformation; CreateOK: boolean; ExitCode: integer; dwExitCode: DWORD; begin ExitCode := -1; FillChar(StartInfo, SizeOf(TStartupInfo), #0); FillChar(ProcInfo, SizeOf(TProcessInformation), #0); StartInfo.cb := SizeOf(TStartupInfo); if WorkDir <> '' then begin CreateOK := CreateProcess(nil, Addr(ProgramName[1]), nil, Addr(WorkDir[1]), false, CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil, nil, StartInfo, ProcInfo); end else begin CreateOK := CreateProcess(nil, Addr(ProgramName[1]), nil, nil, false, CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS, nil, Addr(WorkDir[1]), StartInfo, ProcInfo); end; { check to see if successful } if CreateOK then begin
I tried using the StartInfo.wShowWindow attribute with SW_MINIMIZE , SW_FORCEMINIMIZE and SW_SHOWMINIMIZED , but it does not work. I see that the attribute is changing in the debugger, but as far as I understand it right now. Can anyone indicate what the problem is?
EDIT: If this is important, I execute a couple of Fortran modules (.exe) with arguments that open a CMD window.