Question

I have encountered a problem about the "Console Window" of the Windows CE Platform. To simplify the question ,I wrote this HelloWorld sample application: I wrote my code like this, build ,run . The behavior is really wired. After "double-clicking the application" , If there is not input/output ,I can not see the "Console Window". After 20 seconds ,I printed "helloworld" then I can see the console. I investigated the "printf()", and I can see this API is from "corecrt.lib" and I can not see the source code. I do not know this is the normal behavior ,or there is something wrong with my Application.

Would you give me any advice please. Anything will be appreciated.

//-----------------------------------------------
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
    //After click...there is no window.
    Sleep(20000);

    //20 seconds later ,a window appears.
    printf("HelloWorld!\n");

    return 0;   
}

//----------------------------------------------

Was it helpful?

Solution

It is expected behavior in WinCE.

If there is no input/output needed, console will not appear. That means, the application will run silently on double click.

If you need console window to appear, you have to use printf/scanf/getchar etc.

OTHER TIPS

Under CE, there is no distinction between "windows" and "console" subsystem. On the desktop, those are given to the linker which records this in the executable, so that the OS can launch the according console window when necessary. Instead, it just creates a window when you first use it.

As a workaround, you could output some dummy content like a newline to trigger console window creation. Maybe AllocConsole() (not sure about the name) would also work, at least on the desktop variants it can be used to create a console window even for window programs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top