Running a Win API app. from command line

Started by
1 comment, last by Trip99 18 years, 10 months ago
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?
------------------------See my games programming site at: www.toymaker.info
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.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Hi, thanks - that does make sense. I discovered that if run from a batch file call there is no problem and the prompt returns.
------------------------See my games programming site at: www.toymaker.info

This topic is closed to new replies.

Advertisement