Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3491550
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:39:01+00:00 2026-05-18T11:39:01+00:00

I have a C++ dll reporting lots of useful information via console output using

  • 0

I have a C++ dll reporting lots of useful information via console output using printf or cout. I’m linking this dll to my GUI application written in MFC and want to access its output.

Sounds pretty simple, yeah? Well, I was surprised when after hours of searching internet and implementing several solutions none of them worked!

So maybe some additional information about application is needed. I have a huge host application to which I have no access. Actually, I’m writing plugin to it. It links my plugin dll at runtime (using LoadLibrary(), I suppose). My dll at its turn uses external dll which output I want to acquire. This dll is linked to my statically via corresponding lib file, so CRT does all the loading.

As far as I know, any application (including all loaded in whatever way dll’s) has single stdout stream (single stdin and single stderr). And that’s when things are going too complicated for me. I’ve tried to redirect this stdout stream (obviously, for whole application/process) and in some cases it worked for MY dll, but it still doesn’t work for EXTERNAL dll. I.e. if I use something like cout << "Hey!"; from my dll, I can see this in file to which I’ve redirected stream. However, the same call from inside external dll (yes, I have it’s sources but I really don’t want to change them) does nothing. God knows where this output is done.

I’ve tried:

  1. Good old freopen() trick. Worked for my dll, no effect for external dll.
  2. WinAPI SetStdHandle() call. Doesn’t work at all. Seems to have some troubles with Win7.
  3. AllocConsole() + _open_osfhandle(). Same as 1. See my output in console, see no output of external dll.
  4. cout.rdbuf() reassign. Same as 3 but only for cout.

Well, guys, I really need help. Seems like I’m stuck :-/

Additional info:
Host application, my dll and external dll was developed using MSVS’05. All dlls have “Use MFC in a Static Library” setting. Testing was done under Win7 x64. I do have ALL sources but I have no permission to change them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:39:02+00:00Added an answer on May 18, 2026 at 11:39 am

    You are IIRC getting screwed up by the “Use MFC in a Static Library” setting. Setting/reopening the int (POSIX style) handles won’t work because both your DLL and your application are using differenet/separate run time libraries. Solution: Use the “Use MFC in a Shared DLL” setting. Using static run time libraries on Windows is retarded because of exactly this kind of problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am recording video from webcam using DirectshowLib2005.dll in C#.net..i have this code to
I have DLL and application that will call some function in this dll. For
I have a console application which needs to connect to SQL Reporting Services on
I have a COM dll which I was using in my .net project through
I have a reporting dll that is used in ASP.NET (Windows Authentication) and winforms
I have a shared reporting dll that is used in both windows and web.
I created this class library(ReportLib) with a simple Telerik report using Telerik Reporting Wizard.
I have a .NET application that makes calls to a native Win32 DLL using
I'm pretty new in C#. I have Dll written on C++ by myself and
I have a .dll I'm trying to embed as a resource inside an executable.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.