Question

i trying to print out some logs to console for mfc application

(cuz, i want to execute a this app 2 ways. normally gui way and cui by 'cmd', i won't execute sub console )

i capture console arguments on "CXXXApp::InitInstance()" by

LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);

it works well, but when i print out a message like below

fwprintf_s(stdout blah blah);
wprintf_s( blah blah);
std::wcout<<blah blah;
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), blahblah);

anything does not works on 'cmd'

i think something to lock a stdout and stderr but i cannnot find it


i want to build one executable app that can run in both, windows and console. and i did it but i can not print out logs on console

Was it helpful?

Solution

I don't understand the question being asked, and I guess nobody else either, which is why you haven't received any replies. For example, what does "anything does not works on 'cmd'" mean.

Anyway, if you want to run a GUI application (in the Windows subsystem) and want to write to the console from which you started that application, or if you want to build one executable that can run in both the Windows and Console subsystems, you're out of luck - it's either one or the other. There are various ways to work around this limitation, but without known what you want to do, it's hard to tell which ones are suitable for your situation.

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