🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#2161
From: Lars
Date: Thu, 14 Oct 1999 00:00
108 lines
4055 bytes
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 ?





Klasens <nklasens.aut@rbk.nl> skrev i en
nyhedsmeddelelse:939823221.26090.0.pluto.c3ade75e@news.demon.nl...
> lars <lti@delfi.dk> schreef in berichtnieuws
> 7tsso1$94v$1@news.inet.tele.dk...
> > Hi,
> >
> > I want to grab the textcontent of an active DOS box.
> >
> > - what i DONT want is a solution that "pipes" data another way - like:
> >
> > dir > data.dat
> >
> > since this wont work with an active application - ex EDIT.EXE or another
> > program running until user exits the program.
> >
> > What i would like is to "poll" the DOS box from my application - and get
> the
> > ex. 80*25 characters - and ex. display this in another way in my GUI
> > application.
>
> /////////////////////////////////
>
> #include <windows.h>
>
> VOID main(void)
>
>     HANDLE hStdout;
>     SMALL_RECT srctReadRect;
>     CHAR_INFO chiBuffer[160]; // [2][80];
>     COORD coordBufSize;
>     COORD coordBufCoord;
>     BOOL fSuccess;
>
>     /*
>      * Get a handle of the STDOUT screen buffer to copy from and
>     */
>
>     hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
>     if (hStdout == INVALID_HANDLE_VALUE){
>         /*error code*/
>     }
>     /* Set the source rectangle. */
>     srctReadRect.Top = 0;    /* top left: row 0, col 0  */
>     srctReadRect.Left = 0;
>     srctReadRect.Bottom = 1; /* bot. right: row 1, col 79 */
>     srctReadRect.Right = 79;
>     /* The temporary buffer size is 2 rows x 80 columns. */
>     coordBufSize.Y = 2;
>     coordBufSize.X = 80;
>     /*
>      * The top left destination cell of the temporary buffer is
>      * row 0, col 0.
>      */
>     coordBufCoord.X = 0;
>     coordBufCoord.Y = 0;
>     /* Copy the block from the screen buffer to the temp. buffer. */
>     fSuccess = ReadConsoleOutput(
>        hStdout,        /* screen buffer to read from       */
>        chiBuffer,      /* buffer to copy into              */
>        coordBufSize,   /* col-row size of chiBuffer        */
>
>        coordBufCoord,  /* top left dest. cell in chiBuffer */
>        &srctReadRect); /* screen buffer source rectangle   */
>     if (! fSuccess){
>         /*error code*/
>     }
>
> }
>
>
> /////////////////////////////////
>
> /////////////////////////////////
>
> typedef struct _CHAR_INFO {
>     union {
>         WCHAR UnicodeChar;
>         CHAR   AsciiChar;
>     } Char;
>     WORD Attributes;
> } CHAR_INFO, *PCHAR_INFO;
>
>
> > Can anyone tell me if this is possible ? - im using CreateProcess to
> launch
> > the external application, the dos application will always be
> "windowized" -
> > not a fullscreen box.
>
> > I have looked at AllocConsole....but well...i dont really get the idea
of
> > this.
>
> AllocConsole can't start a application. CreateProcess is the one you need.
>
>
>
Technical Details
Message-ID: <7u2v29$b15$1@news.inet.tele.dk>
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>

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: "Lars" <lti@delfi.dk>
Subject: Sv: Grab Screen from active DOS/console App. ?
Date: 1999/10/14
Message-ID: <7u2v29$b15$1@news.inet.tele.dk>
X-Deja-AN: 536414915
References: <7tsso1$94v$1@news.inet.tele.dk> <939823221.26090.0.pluto.c3ade75e@news.demon.nl>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Complaints-To: Department of Abuse <abuse@news.inet.tele.dk>
X-Trace: news.inet.tele.dk 939851657 11301 195.249.35.190 (13 Oct 1999 21:54:17 GMT)
Organization: Customer of Tele Danmark Internet
X-MSMail-Priority: Normal
NNTP-Posting-Date: 13 Oct 1999 21:54:17 GMT
Newsgroups: comp.os.ms-windows.programmer.win32,borland.public.cppbuilder.winapi