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 6806515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:43:13+00:00 2026-05-26T19:43:13+00:00

I’ve got a Windows application (written in C, compiled with MSVC Express edition, 32-bit

  • 0

I’ve got a Windows application (written in C, compiled with MSVC Express edition, 32-bit mode), which has two main modes of operation:

  • Windowed mode — create a window, and draw stuff in it (namely, a fractal).
  • Benchmark mode — when run with --benchmark as an argument, don’t make a window but just print some benchmark statistics to stdout.

During development I’ve compiled as a Console app, and used SDL to create the window and perform other GUI functions. So benchmark mode runs fine (no window is created), and graphical mode just has a lingering console window.

However for my release compilation I’ve enabled the Windows subsystem instead of Console. (As explained in this question). This works great except I’ve suddenly discovered I can’t run benchmarks any more. 😮

I’m just wondering, is there a way for an application to choose at run time (e.g. based on the command line it’s given) which kind of subsystem behaviour to use?

I’ve done some experimentation with EXE files in Windows (explorer, notepad, winword) and none of them seem to print anything to the console when run with an argument like “/?” (which most Windows console apps support). So it doesn’t look like it, but I thought it’s worth asking here in case there’s a special trick.

Update. It looks like, no, you can’t. Thanks for the answers guys.

Additional academic question. Does this mean that the subsystem choice is marked in the EXE header, and it’s the operating system that examines this and sets up the Window or connects it to the console it’s run from? I don’t know much about EXE loading, but I would be curious to learn a few details here.

Conclusion. I think there are four good solutions (plus two semi-solutions, making five total :p) to choose from:

  1. Use the console subsystem, but use FreeConsole when running in GUI mode.
  2. Use the windows system, and use AllocConsole when running in benchmark mode. Not perfect if fractal.exe is run from an existing console, so I’ll count this as half a solution ;-).
  3. Just have one executable for each subsystem, fractal.exe and fractalgui.exe.
  4. Have two (or more) executables, one of which does the work and passes it to the other to be displayed on the console or in a Window as appropriate. Needs some thought on how to divide the programs and how to communicate between them.
  5. Another half-solution: have fractalgui.exe print the benchmark to standard out, and pipe that to a utility that will simply print it.

I haven’t yet chosen, but I’m leaning towards #3.

Thanks to Matteo and smerlin for the ideas!

  • 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-26T19:43:13+00:00Added an answer on May 26, 2026 at 7:43 pm

    There is no way a application can choose her subsystem at runtime (well there are some really ugly workarounds, but those are full of quirks).

    Then general solution for this problem is to have a console application, which starts your gui application if necessary

    For your benchmark case, it would just print your benchmark statistics.

    example setup:
    – fractalgui.exe (subsystem: windows)
    – fractal.exe (subsystem: console)

    * the shortcut on the user desktop links to your fractalgui.exe
    * if the user starts fractal.exe from the console, fractal exe starts fractalgui.exe
    * if the user starts fractal.exe --benchmark, it either does the benchmark itself (if its possible to add this benchmark logic to another executable) and prints the information directly to console, or – if thats not possible – it will need to start fractalgui.exe --nogui --benchmark. The tricky case here is to get your output from fractalgui.exe to fractal.exe, so you can print it on the appropriate console. There are several ways to do this, e.g. named pipes (there are ways to start fractalgui.exe in a way, that you can just use stdout / cout there, and the data will be piped to the stdout of fractal.exe, but i dont recall how excactly this works anymore (edit: maybe this works)). The easiest way would be to start fractalgui.exe --nogui --benchmark > mylogfile and then print mylogfile after fractalgui.exe finished (since stdout/cout of fractalgui.exe will work if the output is redirected to a file), however you wont get “live” output, since all the output will be printed on the console when fractalgui.exe is already finished.

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from

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.