Jump to content
  • Advertisement
Sign in to follow this  

Running a Win API app. from command line

This topic is 4724 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a win32 app (using DirectX) that I want to be able to run from the command line as an option (it is a program for creating terrain textures). Now I have pretty much got it working apart from one minor issue. I detect when it is run from a cmd prompt and then do AttachConsole( ATTACH_PARENT_PROCESS ) I can then write to the console with WriteConsole(...) fine. When closing down I call FreeConsole() Now the problem I have is that the command prompt does not return to the user - the path is not shown after my program exits. Does anyone know how I can fix this?

Share this post


Link to post
Share on other sites
Advertisement
I just tested this out, and I found that the control does in fact return to the console - in fact control is never actually taken away from the console. I can still type and execute commands in the console window even while my code loops and writes text out. The tricky thing is that execution returns to the command line right away after the app's message loop starts, so the prompt actually prints right after you press Enter (more or less). Once the output starts, the prompt usually gets erased or lost, and when the program exits, the cursor just sits there looking dead.

Somehow the app needs to block the command line until execution finishes, which is a bit tricky because the app runs in a separate process and thread space. Unfortunately I can't offer you any good suggestions for getting around this, but maybe that will get you started.

Share this post


Link to post
Share on other sites
Hi, thanks - that does make sense. I discovered that if run from a batch file call there is no problem and the prompt returns.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!