Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Artur Ryt
KWSys
Commits
b9890dc0
Commit
b9890dc0
authored
21 years ago
by
Brad King
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Added show/hide window support.
parent
b7de58ae
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ProcessFwd9x.c
+9
-1
9 additions, 1 deletion
ProcessFwd9x.c
ProcessWin32.c
+22
-22
22 additions, 22 deletions
ProcessWin32.c
with
31 additions
and
23 deletions
ProcessFwd9x.c
+
9
−
1
View file @
b9890dc0
...
...
@@ -54,6 +54,9 @@ int main()
This is parsed off the command line. */
HANDLE
killEvent
=
0
;
/* Flag for whether to hide window of child process. */
int
hideWindow
=
0
;
/* An array of the handles on which we wait when the child is
running. */
HANDLE
waitHandles
[
2
]
=
{
0
,
0
};
...
...
@@ -79,6 +82,11 @@ int main()
while
(
*
cmdLine
&&
*
cmdLine
==
' '
)
{
++
cmdLine
;
}
sscanf
(
cmdLine
,
"%p"
,
&
killEvent
);
/* Parse the hide window flag. */
while
(
*
cmdLine
&&
*
cmdLine
!=
' '
)
{
++
cmdLine
;
}
while
(
*
cmdLine
&&
*
cmdLine
==
' '
)
{
++
cmdLine
;
}
sscanf
(
cmdLine
,
"%d"
,
&
hideWindow
);
/* Skip to the beginning of the command line of the real child. */
while
(
*
cmdLine
&&
*
cmdLine
!=
' '
)
{
++
cmdLine
;
}
while
(
*
cmdLine
&&
*
cmdLine
==
' '
)
{
++
cmdLine
;
}
...
...
@@ -88,7 +96,7 @@ int main()
ZeroMemory
(
&
pi
,
sizeof
(
pi
));
si
.
cb
=
sizeof
(
si
);
si
.
dwFlags
=
STARTF_USESTDHANDLES
|
STARTF_USESHOWWINDOW
;
si
.
wShowWindow
=
SW_SHOWDEFAULT
;
si
.
wShowWindow
=
hideWindow
?
SW_HIDE
:
SW_SHOWDEFAULT
;
si
.
hStdInput
=
GetStdHandle
(
STD_INPUT_HANDLE
);
si
.
hStdOutput
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
si
.
hStdError
=
GetStdHandle
(
STD_ERROR_HANDLE
);
...
...
This diff is collapsed.
Click to expand it.
ProcessWin32.c
+
22
−
22
View file @
b9890dc0
...
...
@@ -140,6 +140,9 @@ struct kwsysProcess_s
/* The working directory for the child process. */
char
*
WorkingDirectory
;
/* Whether to hide the child process's window. */
int
HideWindow
;
/* On Win9x platforms, the path to the forwarding executable. */
char
*
Win9x
;
...
...
@@ -638,17 +641,21 @@ void kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
/*--------------------------------------------------------------------------*/
int
kwsysProcess_GetOption
(
kwsysProcess
*
cp
,
int
optionId
)
{
(
void
)
cp
;
(
void
)
optionId
;
return
0
;
switch
(
optionId
)
{
case
kwsysProcess_Option_HideWindow
:
return
cp
->
HideWindow
;
default:
return
0
;
}
}
/*--------------------------------------------------------------------------*/
void
kwsysProcess_SetOption
(
kwsysProcess
*
cp
,
int
optionId
,
int
value
)
{
(
void
)
cp
;
(
void
)
optionId
;
(
void
)
value
;
switch
(
optionId
)
{
case
kwsysProcess_Option_HideWindow
:
cp
->
HideWindow
=
value
;
break
;
default:
break
;
}
}
/*--------------------------------------------------------------------------*/
...
...
@@ -692,6 +699,7 @@ void kwsysProcess_Execute(kwsysProcess* cp)
/* Windows child startup control data. */
STARTUPINFO
si
;
DWORD
dwCreationFlags
=
0
;
/* Do not execute a second time. */
if
(
cp
->
State
==
kwsysProcess_State_Executing
)
...
...
@@ -761,39 +769,31 @@ void kwsysProcess_Execute(kwsysProcess* cp)
/* The forwarding executable is given a handle to the error pipe
and a handle to the kill event. */
cp
->
RealCommand
=
malloc
(
strlen
(
cp
->
Win9x
)
+
strlen
(
cp
->
Command
)
+
100
);
sprintf
(
cp
->
RealCommand
,
"%s %p %p %s"
,
cp
->
Win9x
,
cp
->
Pipe
[
CMPE_PIPE_ERROR
].
Write
,
cp
->
Win9xKillEvent
,
cp
->
Command
);
sprintf
(
cp
->
RealCommand
,
"%s %p %p
%d
%s"
,
cp
->
Win9x
,
cp
->
Pipe
[
CMPE_PIPE_ERROR
].
Write
,
cp
->
Win9xKillEvent
,
cp
->
HideWindow
,
cp
->
Command
);
}
else
{
/* Not Windows 9x */
cp
->
RealCommand
=
strdup
(
cp
->
Command
);
}
/* Connect the child's output pipes to the threads. */
si
.
dwFlags
=
STARTF_USESTDHANDLES
;
si
.
hStdOutput
=
cp
->
Pipe
[
CMPE_PIPE_STDOUT
].
Write
;
si
.
hStdError
=
cp
->
Pipe
[
CMPE_PIPE_STDERR
].
Write
;
/* Hide the forwarding executable console on Windows 9x. */
si
.
dwFlags
|=
STARTF_USESHOWWINDOW
;
if
(
cp
->
Win9x
)
{
si
.
wShowWindow
=
SW_HIDE
;
}
else
{
si
.
wShowWindow
=
SW_SHOWDEFAULT
;
}
/* Decide whether a child window should be shown. */
si
.
dwFlags
|=
STARTF_USESHOWWINDOW
;
si
.
wShowWindow
=
cp
->
HideWindow
?
SW_HIDE
:
SW_SHOWDEFAULT
;
/* The timeout period starts now. */
cp
->
StartTime
=
kwsysProcessTimeGetCurrent
();
cp
->
TimeoutTime
=
kwsysProcessTimeFromDouble
(
-
1
);
/* CREATE THE CHILD PROCESS */
if
(
!
CreateProcess
(
0
,
cp
->
RealCommand
,
0
,
0
,
TRUE
,
cp
->
Win9x
?
CREATE_NEW_CONSOLE
:
DETACHED_PROCESS
,
0
,
if
(
!
CreateProcess
(
0
,
cp
->
RealCommand
,
0
,
0
,
TRUE
,
dwCreationFlags
,
0
,
cp
->
WorkingDirectory
,
&
si
,
&
cp
->
ProcessInformation
))
{
kwsysProcessCleanup
(
cp
,
1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment