🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.win32
Article #2162

Re: Grab Screen from active DOS/console App. ?

#2162
From: Klasens
Date: Thu, 14 Oct 1999 00:00
199 lines
8591 bytes
Lars <lti@delfi.dk> schreef in berichtnieuws
7u2v29$b15$1@news.inet.tele.dk...
> thanks ! - this is exactly what i meant; - works fine.
>
> though i have some troubles with CreateProcess - how to tell that this
> process is a console job; - because when i launch from my GUI- the STDOUT
is
> (probaly) my GUI - is there any way to retrieve the STDOUT from a newly
> launched Createprocess ?

In CreateProces you can pass a STARTUPINFO struct. Below I will quote a text
about this structure. I hope this will help you.

greetz
Nico Klasens

RBK Automatisering BV
The Netherlands

----------------------------------------------------------------------------
---
The STARTUPINFO structure is used with the CreateProcess function to specify
main window properties if a new window is created for the new process. For
graphical user interface (GUI) processes, this information affects the first
window created by the CreateWindow function and shown by the ShowWindow
function. For console processes, this information affects the console window
if a new console is created for the process. A process can use the
GetStartupInfo function to retrieve the STARTUPINFO structure specified when
the process was created.

typedef struct _STARTUPINFO { // si
    DWORD   cb;
    LPTSTR  lpReserved;
    LPTSTR  lpDesktop;
    LPTSTR  lpTitle;
    DWORD   dwX;
    DWORD   dwY;
    DWORD   dwXSize;
    DWORD   dwYSize;
    DWORD   dwXCountChars;
    DWORD   dwYCountChars;
    DWORD   dwFillAttribute;
    DWORD   dwFlags;
    WORD    wShowWindow;
    WORD    cbReserved2;
    LPBYTE  lpReserved2;
    HANDLE  hStdInput;
    HANDLE  hStdOutput;
    HANDLE  hStdError;

} STARTUPINFO, *LPSTARTUPINFO;


Members

cb

Specifies the size, in bytes, of the structure.

lpReserved

Reserved. Set this member to NULL before passing the structure to
CreateProcess.

lpDesktop

Windows NT only: Points to a zero-terminated string that specifies either
the name of the desktop only or the name of both the window station and
desktop for this process. A backslash in the string pointed to by lpDesktop
indicates that the string includes both desktop and window station names.
Otherwise, the lpDesktop string is interpreted as a desktop name. If
lpDesktop is NULL, the new process inherits the window station and desktop
of its parent process.

lpTitle

For console processes, this is the title displayed in the title bar if a new
console window is created. If NULL, the name of the executable file is used
as the window title instead. This parameter must be NULL for GUI or console
processes that do not create a new console window.

dwX, dwY

Ignored unless dwFlags specifies STARTF_USEPOSITION. Specifies the x and y
offsets, in pixels, of the upper left corner of a window if a new window is
created. The offsets are from the upper left corner of the screen. For GUI
processes, the specified position is used the first time the new process
calls CreateWindow to create an overlapped window if the x parameter of
CreateWindow is CW_USEDEFAULT.

dwXSize, dwYSize

Ignored unless dwFlags specifies STARTF_USESIZE. Specifies the width
(dwXSize) and height (dwYSize), in pixels, of the window if a new window is
created. For GUI processes, this is used only the first time the new process
calls CreateWindow to create an overlapped window if the nWidth parameter of
CreateWindow is CW_USEDEFAULT.

dwXCountChars, dwYCountChars

Ignored unless dwFlags specifies STARTF_USECOUNTCHARS. For console
processes, if a new console window is created, dwXCountChars specifies the
screen buffer width in character columns, and dwYCountChars specifies the
screen buffer height in character rows. These values are ignored in GUI
processes.

dwFillAttribute

Ignored unless dwFlags specifies STARTF_USEFILLATTRIBUTE. Specifies the
initial text and background colors if a new console window is created in a
console application. These values are ignored in GUI applications. This
value can be any combination of the following values: FOREGROUND_BLUE,
FOREGROUND_GREEN, FOREGROUND_RED, FOREGROUND_INTENSITY, BACKGROUND_BLUE,
BACKGROUND_GREEN, BACKGROUND_RED, and BACKGROUND_INTENSITY. For example, the
following combination of values produces red text on a whilte background:

FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE


dwFlags

This is a bit field that determines whether certain STARTUPINFO members are
used when the process creates a window. Any combination of the following
values can be specified:

Value Meaning
STARTF_USESHOWWINDOW If this value is not specified, the wShowWindow member
is ignored.
STARTF_USEPOSITION If this value is not specified, the dwX and dwY members
are ignored.
STARTF_USESIZE If this value is not specified, the dwXSize and dwYSize
members are ignored.
STARTF_USECOUNTCHARS If this value is not specified, the dwXCountChars and
dwYCountChars members are ignored.
STARTF_USEFILLATTRIBUTE If this value is not specified, the dwFillAttribute
member is ignored.
STARTF_FORCEONFEEDBACK If this value is specified, the cursor is in feedback
mode for two seconds after CreateProcess is called. If during those two
seconds the process makes the first GUI call, the system gives five more
seconds to the process. If during those five seconds the process shows a
window, the system gives five more seconds to the process to finish drawing
the window.
The system turns the feedback cursor off after the first call to GetMessage,
regardless of whether the process is drawing.
For more information on feedback, see the following Remarks section.
STARTF_FORCEOFFFEEDBACK If specified, the feedback cursor is forced off
while the process is starting. The normal cursor is displayed. For more
information on feedback, see the following Remarks section.
STARTF_USESTDHANDLES If this value is specified, sets the standard input of
the process, standard output, and standard error handles to the handles
specified in the hStdInput, hStdOutput, and hStdError members of the
STARTUPINFO structure. The CreateProcess function's fInheritHandles
parameter must be set to TRUE for this to work properly.
If this value is not specified, the hStdInput, hStdOutput, and hStdError
members of the STARTUPINFO structure are ignored.


wShowWindow

Ignored unless dwFlags specifies STARTF_USESHOWWINDOW. The wshowWindow
member can be any of the SW_ constants defined in WINUSER.H. For GUI
processes, wShowWindow specifies the default value the first time ShowWindow
is called. The nCmdShow parameter of ShowWindow is ignored. In subsequent
calls to ShowWindow, the wShowWindow member is used if the nCmdShow
parameter of ShowWindow is set to SW_SHOWDEFAULT.

cbReserved2

Reserved; must be zero.

lpReserved2

Reserved; must be NULL.

hStdInput

Ignored unless dwFlags specifies STARTF_USESTDHANDLES. Specifies a handle
that will be used as the standard input handle of the process if
STARTF_USESTDHANDLES is specified.

hStdOutput

Ignored unless dwFlags specifies STARTF_USESTDHANDLES. Specifies a handle
that will be used as the standard output handle of the process if
STARTF_USESTDHANDLES is specified.

hStdError

Ignored unless dwFlags specifies STARTF_USESTDHANDLES. Specifies a handle
that will be used as the standard error handle of the process if
STARTF_USESTDHANDLES is specified.



Remarks

If a GUI process is being started and neither STARTF_FORCEONFEEDBACK or
STARTF_FORCEOFFFEEDBACK is specified, the process feedback cursor is used. A
GUI process is one whose subsystem is specified as "windows."
Technical Details
Message-ID: <939887142.27888.0.pluto.d4ee8199@news.demon.nl>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7tsso1$94v$1@news.inet.tele.dk> <939823221.26090.0.pluto.c3ade75e@news.demon.nl> <7u2v29$b15$1@news.inet.tele.dk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113dfb,c93ee5508c9ac840
X-Google-Attributes: gid113dfb,public
X-Google-Thread: f5ca7,c93ee5508c9ac840
X-Google-Attributes: gidf5ca7,public
From: "Klasens" <nklasens.aut@rbk.nl>
Subject: Re: Grab Screen from active DOS/console App. ?
Date: 1999/10/14
Message-ID: <939887142.27888.0.pluto.d4ee8199@news.demon.nl>
X-Deja-AN: 536567093
X-NNTP-Posting-Host: rbkgroep2.demon.nl:212.238.129.153
References: <7tsso1$94v$1@news.inet.tele.dk> <939823221.26090.0.pluto.c3ade75e@news.demon.nl> <7u2v29$b15$1@news.inet.tele.dk>
X-Priority: 3
X-Mimeole: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Complaints-To: abuse@demon.net
X-Trace: news.demon.nl 939887142 pluto:27888 NO-IDENT rbkgroep2.demon.nl:212.238.129.153
X-MSMail-Priority: Normal
Newsgroups: comp.os.ms-windows.programmer.win32,borland.public.cppbuilder.winapi