process: explode with blocks

git-svn-id: trunk@46343 -
This commit is contained in:
ondrej 2020-08-09 16:30:53 +00:00
parent 4f5881531b
commit b168045119

View File

@ -44,49 +44,43 @@ end;
Function GetStartupFlags (P : TProcessnamemacro): Cardinal; Function GetStartupFlags (P : TProcessnamemacro): Cardinal;
begin begin
With P do Result:=0;
begin if poUsePipes in P.Options then
Result:=0; Result:=Result or Startf_UseStdHandles;
if poUsePipes in Options then if suoUseShowWindow in P.StartupOptions then
Result:=Result or Startf_UseStdHandles; Result:=Result or startf_USESHOWWINDOW;
if suoUseShowWindow in StartupOptions then if suoUSESIZE in P.StartupOptions then
Result:=Result or startf_USESHOWWINDOW; Result:=Result or startf_usesize;
if suoUSESIZE in StartupOptions then if suoUsePosition in P.StartupOptions then
Result:=Result or startf_usesize; Result:=Result or startf_USEPOSITION;
if suoUsePosition in StartupOptions then if suoUSECOUNTCHARS in P.Startupoptions then
Result:=Result or startf_USEPOSITION; Result:=Result or startf_usecountchars;
if suoUSECOUNTCHARS in Startupoptions then if suoUsefIllAttribute in P.StartupOptions then
Result:=Result or startf_usecountchars; Result:=Result or startf_USEFILLATTRIBUTE;
if suoUsefIllAttribute in StartupOptions then
Result:=Result or startf_USEFILLATTRIBUTE;
end;
end; end;
Function GetCreationFlags(P : TProcessnamemacro) : Cardinal; Function GetCreationFlags(P : TProcessnamemacro) : Cardinal;
begin begin
With P do Result:=CREATE_UNICODE_ENVIRONMENT;
begin if poNoConsole in P.Options then
Result:=CREATE_UNICODE_ENVIRONMENT; Result:=Result or CREATE_NO_WINDOW;
if poNoConsole in Options then if poNewConsole in P.Options then
Result:=Result or CREATE_NO_WINDOW; Result:=Result or Create_new_console;
if poNewConsole in Options then if poNewProcessGroup in P.Options then
Result:=Result or Create_new_console; Result:=Result or CREATE_NEW_PROCESS_GROUP;
if poNewProcessGroup in Options then If poRunSuspended in P.Options Then
Result:=Result or CREATE_NEW_PROCESS_GROUP; Result:=Result or Create_Suspended;
If poRunSuspended in Options Then if poDebugProcess in P.Options Then
Result:=Result or Create_Suspended; Result:=Result or DEBUG_PROCESS;
if poDebugProcess in Options Then if poDebugOnlyThisProcess in P.Options Then
Result:=Result or DEBUG_PROCESS; Result:=Result or DEBUG_ONLY_THIS_PROCESS;
if poDebugOnlyThisProcess in Options Then if poDefaultErrorMode in P.Options Then
Result:=Result or DEBUG_ONLY_THIS_PROCESS; Result:=Result or CREATE_DEFAULT_ERROR_MODE;
if poDefaultErrorMode in Options Then if poDetached in P.Options Then
Result:=Result or CREATE_DEFAULT_ERROR_MODE; Result:=Result or DETACHED_PROCESS;
if poDetached in Options Then
Result:=Result or DETACHED_PROCESS;
result:=result or PriorityConstants[FProcessPriority]; result:=result or PriorityConstants[P.FProcessPriority];
end;
end; end;
function WStrAsUniquePWideChar(var s: UnicodeString): PWideChar; function WStrAsUniquePWideChar(var s: UnicodeString): PWideChar;
@ -137,31 +131,28 @@ Const
begin begin
FillChar(SI,SizeOf(SI),0); FillChar(SI,SizeOf(SI),0);
With SI do SI.cb:=SizeOf(SI);
SI.dwFlags:=GetStartupFlags(P);
if P.FShowWindow<>swoNone then
SI.dwFlags:=SI.dwFlags or Startf_UseShowWindow
else
SI.dwFlags:=SI.dwFlags and not Startf_UseShowWindow;
SI.wShowWindow:=SWC[P.FShowWindow];
if (poUsePipes in P.Options) then
begin begin
cb:=SizeOf(SI); SI.dwFlags:=SI.dwFlags or Startf_UseStdHandles;
dwFlags:=GetStartupFlags(P); end;
if P.FShowWindow<>swoNone then if P.FillAttribute<>0 then
dwFlags:=dwFlags or Startf_UseShowWindow begin
else SI.dwFlags:=SI.dwFlags or Startf_UseFillAttribute;
dwFlags:=dwFlags and not Startf_UseShowWindow; SI.dwFillAttribute:=P.FillAttribute;
wShowWindow:=SWC[P.FShowWindow]; end;
if (poUsePipes in P.Options) then SI.dwXCountChars:=P.WindowColumns;
begin SI.dwYCountChars:=P.WindowRows;
dwFlags:=dwFlags or Startf_UseStdHandles; SI.dwYsize:=P.WindowHeight;
end; SI.dwXsize:=P.WindowWidth;
if P.FillAttribute<>0 then SI.dwy:=P.WindowTop;
begin SI.dwX:=P.WindowLeft;
dwFlags:=dwFlags or Startf_UseFillAttribute;
dwFillAttribute:=P.FillAttribute;
end;
dwXCountChars:=P.WindowColumns;
dwYCountChars:=P.WindowRows;
dwYsize:=P.WindowHeight;
dwXsize:=P.WindowWidth;
dwy:=P.WindowTop;
dwX:=P.WindowLeft;
end;
end; end;
{ The handles that are to be passed to the child process must be { The handles that are to be passed to the child process must be