473,320 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to Modify Console output AFTER it has gone to cout

Is this possible using ANSI libraries? If I have an exe that calls a
black box DLL, and the DLL writes to the console, how can I get my exe
to grab what the DLL wrote, modify it, and spit out a modified form of
said output?

many thanks in advance,
Robby

Aug 6 '07 #1
9 1951
re*******@gmail.com wrote:
Is this possible using ANSI libraries?
What does "ANSI libraries" mean? Do you mean "the Standard Library"?
If so, the answer is "no".
If I have an exe that calls a
black box DLL, and the DLL writes to the console, how can I get my exe
to grab what the DLL wrote, modify it, and spit out a modified form of
said output?
You can try to "capture" or "redirect" the standard output in a different
stream, and then you can do anything you want with that stream's buffer.
Standard output redirection, however, is implementation- and platform-
specific. Ask in the newsgroup for your OS or your compiler.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 6 '07 #2
Alf P. Steinbach schrieb:
* re*******@gmail.com:
>Is this possible using ANSI libraries? If I have an exe that calls a
black box DLL, and the DLL writes to the console, how can I get my exe
to grab what the DLL wrote, modify it, and spit out a modified form of
said output?

The C++ standard doesn't mention "ANSI libraries", "exe", "black box",
"DLL", or "console".

IOW., you're way off-topic -- pray tell, why didn't you post in a Java
group?

Please, next time, do so, or, see the FAQ which lists a number of
Windows programming group suggestions.
Why do you suggest a Java group?

--
Thomas
http://www.netmeister.org/news/learn2quote.html
Aug 6 '07 #3
On Aug 6, 7:39 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
realro...@gmail.com wrote:
Is this possible using ANSI libraries?
What does "ANSI libraries" mean? Do you mean "the Standard Library"?
If so, the answer is "no".
If I have an exe that calls a
black box DLL, and the DLL writes to the console, how can I get my exe
to grab what the DLL wrote, modify it, and spit out a modified form of
said output?
You can try to "capture" or "redirect" the standard output in a different
stream, and then you can do anything you want with that stream's buffer.
Standard output redirection, however, is implementation- and platform-
specific. Ask in the newsgroup for your OS or your compiler.
It's not too clear to me what the situation actually is. If the
DLL outputs to cout/cerr, it's relatively simple to connect
these streams to your own filtering streambuf, and do whatever
you want. If the DLL outputs using system level functions (the
Windows equivalent of write), then there's probably nothing he
can do.

--
James Kanze (GABI Software) email:james.kanze:gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Aug 6 '07 #4

Alf P. Steinbach <al***@start.nowrote in message...
* Thomas J. Gritzan:
Alf P. Steinbach schrieb:
>
IOW., you're way off-topic -- pray tell, why didn't you post in a
Java
group?
[snip]

Why do you suggest a Java group?

Why not? <g>
Does Starbucks count as a 'Java group'?

Hi Alf.
--
Bob <GR
POVrookie
Aug 7 '07 #5
On Aug 6, 5:22 pm, James Kanze <james.ka...@gmail.comwrote:
On Aug 6, 7:39 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
realro...@gmail.com wrote:
Is this possible using ANSI libraries?
What does "ANSI libraries" mean? Do you mean "the Standard Library"?
If so, the answer is "no".
If I have an exe that calls a
black box DLL, and the DLL writes to the console, how can I get my exe
to grab what the DLL wrote, modify it, and spit out a modified form of
said output?
You can try to "capture" or "redirect" the standard output in a different
stream, and then you can do anything you want with that stream's buffer.
Standard output redirection, however, is implementation- and platform-
specific. Ask in the newsgroup for your OS or your compiler.

It's not too clear to me what the situation actually is. If the
DLL outputs to cout/cerr, it's relatively simple to connect
these streams to your own filtering streambuf, and do whatever
you want. If the DLL outputs using system level functions (the
Windows equivalent of write), then there's probably nothing he
can do.

--
James Kanze (GABI Software) email:james.kanze:gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Err, yes, I meant STL libraries, not ANSI libraries. The DLL outputs
through low-level functions and not throuh std::cout or std::cerr,
which is why setting up a filter isn't a trivial task. I was just
wondering if the STL libraries could do anything, as I tend to avoid
platform-dependent code where possible. I gather from the replies that
it's not as simple as I'd hoped.

Thanks,
Robby

Aug 7 '07 #6
On Aug 7, 6:50 pm, realro...@gmail.com wrote:
Err, yes, I meant STL libraries, not ANSI libraries. The DLL outputs
through low-level functions and not throuh std::cout or std::cerr,
which is why setting up a filter isn't a trivial task. I was just
wondering if the STL libraries could do anything, as I tend to avoid
platform-dependent code where possible. I gather from the replies that
it's not as simple as I'd hoped.
In that case, there may be nothing you can do. There's
certainly nothing portable. About the only thing I can suggest
is closing the file descripters (handles under Windows?) for
standard out and standard error, and trying to reopen them to
something else. (This would be the usual solution under Unix,
but it might also work under Windows.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Aug 8 '07 #7

Alf P. Steinbach <al***@start.nowrote in message...
* BobR:
Alf P. Steinbach <al***@start.nowrote in message...
* Thomas J. Gritzan:
[snip]
>Why do you suggest a Java group?
Why not? <g>
Does Starbucks count as a 'Java group'?

Hi Alf.

Hm. Well. :-)

I think perhaps "Hi Alf" is off-topic in this group, but AFAICS the FAQ
doesn't list any more suitable group...
<Grrrrr>

#include <iostream>
int main(){
std::cout<<"Hello Mr. Steinbach."<<std::endl;
return 0;
} // :-}

--
Bob <GR
POVrookie
Aug 9 '07 #8
BobR wrote:
Alf P. Steinbach <al***@start.nowrote in message...
>* BobR:
>>Alf P. Steinbach <al***@start.nowrote in message...
* Thomas J. Gritzan:
[snip]
Why do you suggest a Java group?
Why not? <g>
Does Starbucks count as a 'Java group'?

Hi Alf.
Hm. Well. :-)

I think perhaps "Hi Alf" is off-topic in this group, but AFAICS the FAQ
doesn't list any more suitable group...

<Grrrrr>

#include <iostream>
int main(){
std::cout<<"Hello Mr. Steinbach."<<std::endl;
return 0;
} // :-}
What... No templates?

#include <iostream>

class Alf { };

template<typename T>
void say_hi_to_newsgroup(const T&)
{
std::cout << "Hi Newsgroup!" << std::endl;
}

template<>
void say_hi_to_newsgroup<Alf>(const Alf&)
{
std::cout << "Hello Mr. Steinbach." << std::endl;
}

int main()
{
say_hi_to_newsgroup(Alf());
return 0;
}
Aug 9 '07 #9

red floyd <no*****@here.dudewrote in message...
BobR wrote:
Alf P. Steinbach <al***@start.nowrote in message...
* BobR:
Alf P. Steinbach <al***@start.nowrote in message...
* Thomas J. Gritzan:
[snip]
Why do you suggest a Java group?
Why not? <g>
Does Starbucks count as a 'Java group'?

Hi Alf.
Hm. Well. :-)

I think perhaps "Hi Alf" is off-topic in this group, but AFAICS the FAQ
doesn't list any more suitable group...
<Grrrrr>

#include <iostream>
int main(){
std::cout<<"Hello Mr. Steinbach."<<std::endl;
return 0;
} // :-}

What... No templates?
KISS prevented me from doing that (Homey don't play dat!).

--
Bob <GR
POVrookie
Aug 9 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bob Hartung | last post by:
Hi all, I need to print the extended character set, the corners, vertical bars, crossing bars , etc in a console app. I can fudge it with #define topT char( 194 ) ; then, cout topT ;
1
by: Tony Boloney | last post by:
Hi all, I'm trying to use the method described in the article Adding Console I/O to a Win32 GUI App http://dslweb.nwnexus.com/~ast/dload/guicon.htm to output info to a separate console...
6
by: radnoraj | last post by:
Hi, I am sucessfull in redirecting console output to a file. but in this case nothing is displayed on the console, cout output is written to file without display. how do write the output to...
7
by: Miktor | last post by:
At the minute I am using the following rather unwieldy function to prevent the console window in Dev C++ from closing before I can see the output from my program: // function to prevent the...
4
by: All Rise | last post by:
If I cant or should not use cout, whats the alternate for outputting to the console in c++. Printf() ?
3
by: Gureet Singh | last post by:
Hi This is my first day with C++. Iwas running the following program #include<iostream.h> #include<conio.h> main() { int x,y,z; cout<< " input x,y \n"; cin>> x >> y;
2
by: wizofaus | last post by:
Given the following code: public class Test { static unsafe void StringManip(string data) { fixed (char* ps = data) ps = '$'; }
8
by: Vasileios Zografos | last post by:
Hi, I am trying to output some numbers on the console (command prompt) using the std::cout command. If I do the following: for (int i=1;i<=10;i++) std::cout<<i; the output will be:
8
by: s0suk3 | last post by:
Hi everyone, I've heard that a 'str' object is immutable. But is there *any* way to modify a string's internal value? Thanks, Sebastian
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.