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

  • Home
  • SEARCH
  • 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 9241553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:23:25+00:00 2026-06-18T08:23:25+00:00

What i want: An application, where there are a gui window and console window.

  • 0

What i want:

An application, where there are a gui window and console window. Window can be clicked on, dragged, etcetera. At any given moment, console can be chosen, and a line entered, that will be processed.

What i already have:

An application, that allocates and attaches console to itself, then redirects standard streams to it. Code is:

AllocConsole() ;
AttachConsole( GetCurrentProcessId()); 
freopen("CONIN$","rb",stdin);   // reopen stdin handle as console window input

freopen("CONOUT$","wb",stdout);  // reopen stout handle as console window output

freopen("CONOUT$","wb",stderr); // reopen stderr handle as console window output

Then registers window class, creates and shows a window. Output into console works fine, interaction with window is correct.

However, i cannot input anything into console. I can make a guess about it: if i call something like std::cin >> my_string, i will be able to enter a line – but interaction with a window will stop until the input is completed. Is that correct? How can i make application behave in a way i described above?

update:

I have found related question: Test if stdin has input for C++ (windows and/or linux)

The code for determining, whether there are characters in console input was given there as follows:

bool StdinOpen() {
  static HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
  DWORD bytes_left;
  PeekNamedPipe(handle, NULL, 0, NULL, &bytes_left, NULL);
  return bytes_left;
}

However, it returns some exorbitant numbers, as if there always is input in console.

  • 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-06-18T08:23:26+00:00Added an answer on June 18, 2026 at 8:23 am

    I’d start by initializing the bytes_left variable and check the return value.

    bool StdinOpen() {
      static HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
      DWORD bytes_left = 0;
      if (!PeekNamedPipe(handle, NULL, 0, NULL, &bytes_left, NULL))
         return false;
      return bytes_left != 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to build a lock screen replacement application. Is there any way to
I'm developing a Silverlight application where I want to simulate a console. There are
I have an application in which there is a form which I want to
In my application four TextArea is there and I want to enter only four
I want to play Audio in flex application.I am using SWFLoader for it.Is there
Is there something like SESSION in Windows application? I want to store a few
I want to develop and deploy application on iPhone and Android. However there is
Is there a way to make an application uninstall itself? For example: I want
I want to use ip camera as webcam in my application. is there an
In my application, there is one button in the navigation bar. I want it

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.