Article View: comp.os.ms-windows.programmer.win32
Article #2164Re: Grab Screen from active DOS/console App. ?
From: Klasens
Date: Wed, 13 Oct 1999 00:00
Date: Wed, 13 Oct 1999 00:00
91 lines
3362 bytes
3362 bytes
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:
<939823221.26090.0.pluto.c3ade75e@news.demon.nl>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7tsso1$94v$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/13 Message-ID: <939823221.26090.0.pluto.c3ade75e@news.demon.nl> X-Deja-AN: 536243904 X-NNTP-Posting-Host: rbkgroep.demon.nl:195.173.231.94 References: <7tsso1$94v$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 939823221 pluto:26090 NO-IDENT rbkgroep.demon.nl:195.173.231.94 X-MSMail-Priority: Normal Newsgroups: comp.os.ms-windows.programmer.win32,borland.public.cppbuilder.winapi