mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 20:59:12 +02:00
lazutils: TProcessUTF8: using CreateProcessW on MSWindows, using alias otherwise
git-svn-id: trunk@50603 -
This commit is contained in:
parent
4a1345e0f6
commit
93a809284f
@ -19,7 +19,7 @@ unit UTF8Process;
|
|||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
{$DEFINE UseOldTProcess}
|
{ $DEFINE UseOldTProcess}
|
||||||
|
|
||||||
{$IFNDEF UseOldTProcess}
|
{$IFNDEF UseOldTProcess}
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
@ -353,15 +353,16 @@ Const
|
|||||||
(HIGH_PRIORITY_CLASS,IDLE_PRIORITY_CLASS,
|
(HIGH_PRIORITY_CLASS,IDLE_PRIORITY_CLASS,
|
||||||
NORMAL_PRIORITY_CLASS,REALTIME_PRIORITY_CLASS);
|
NORMAL_PRIORITY_CLASS,REALTIME_PRIORITY_CLASS);
|
||||||
|
|
||||||
function WStrAsP(s: UnicodeString): PWideChar; inline;
|
function WStrAsUniquePWideChar(s: UnicodeString): PWideChar; inline;
|
||||||
begin
|
begin
|
||||||
|
UniqueString(s);
|
||||||
if s<>'' then
|
if s<>'' then
|
||||||
Result:=PWideChar(s)
|
Result:=PWideChar(s)
|
||||||
else
|
else
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function GetStartupFlags (P : TProcess): Cardinal;
|
Function GetStartupFlags (P : TProcessUTF8): Cardinal;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=0;
|
||||||
@ -379,10 +380,10 @@ begin
|
|||||||
Result:=Result or startf_USEFILLATTRIBUTE;
|
Result:=Result or startf_USEFILLATTRIBUTE;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function GetCreationFlags(P : TProcess) : Cardinal;
|
Function GetCreationFlags(P : TProcessUTF8) : Cardinal;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=CREATE_UNICODE_ENVIRONMENT;
|
||||||
if poNoConsole in P.Options then
|
if poNoConsole in P.Options then
|
||||||
Result:=Result or Detached_Process;
|
Result:=Result or Detached_Process;
|
||||||
if poNewConsole in P.Options then
|
if poNewConsole in P.Options then
|
||||||
@ -447,7 +448,7 @@ begin
|
|||||||
TA.nLength := SizeOf(TA);
|
TA.nLength := SizeOf(TA);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure InitStartupInfo(P : TProcess; Out SI : STARTUPINFOW);
|
Procedure InitStartupInfo(P : TProcessUTF8; Out SI : STARTUPINFOW);
|
||||||
|
|
||||||
Const
|
Const
|
||||||
SWC : Array [TShowWindowOptions] of Cardinal =
|
SWC : Array [TShowWindowOptions] of Cardinal =
|
||||||
@ -622,13 +623,11 @@ begin
|
|||||||
CreatePipes(HI{%H-},HO{%H-},HE{%H-},FStartupInfo,Not(poStdErrToOutPut in Options), PipeBufferSize);
|
CreatePipes(HI{%H-},HO{%H-},HE{%H-},FStartupInfo,Not(poStdErrToOutPut in Options), PipeBufferSize);
|
||||||
Try
|
Try
|
||||||
// Beware: CreateProcess can alter the strings
|
// Beware: CreateProcess can alter the strings
|
||||||
UniqueString(WName);
|
// Beware: nil is not the same as a pointer to a #0
|
||||||
UniqueString(WCommandLine);
|
PWName:=WStrAsUniquePWideChar(WName);
|
||||||
UniqueString(WDir);
|
PWCommandLine:=WStrAsUniquePWideChar(WCommandLine);
|
||||||
|
PWDir:=WStrAsUniquePWideChar(WDir);
|
||||||
|
|
||||||
PWName:=WStrAsP(WName);
|
|
||||||
PWCommandLine:=WStrAsP(WCommandLine);
|
|
||||||
PWDir:=WStrAsP(WDir);
|
|
||||||
If Not CreateProcessW (PWName,PWCommandLine,@FProcessAttributes,@FThreadAttributes,
|
If Not CreateProcessW (PWName,PWCommandLine,@FProcessAttributes,@FThreadAttributes,
|
||||||
InheritHandles,FCreationFlags,FEnv,PWDir,FStartupInfo,
|
InheritHandles,FCreationFlags,FEnv,PWDir,FStartupInfo,
|
||||||
fProcessInformation{%H-}) then
|
fProcessInformation{%H-}) then
|
||||||
|
Loading…
Reference in New Issue
Block a user