/ SUBSYSTEM: Windows program will not write on the command line

I have a C ++ - CLI mixed program in Visual Studio 2005 that is configured to use / SUBSYSTEM: Windows. Generally speaking, this is a graphical application that is launched from its shortcut or through the file type registered on it.

However, there is a rare case when a user wants to run it from the command line with arguments. I can easily access the arguments when it comes to writing to the console, in response to running the program from the command line with arguments, where I see no effect Console::WriteLine.

What am I doing wrong?

+3
source share
2 answers

, . , , Windows.

, , . http://blogs.msdn.com/junfeng/archive/2004/02/06/68531.aspx. , .

IME , ( "myapp.exe" ), - ( "myappw.exe" ).

++/Windows .

+3

- . http://www.codeproject.com/KB/cpp/EditBin.aspx

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE /*hPrevInst*/, LPSTR cmd_line, int showmode)
{
  AllocConsole(); //create a console
  ifstream conin("con");   // not sure if this should be "con:" ?
  ofstream conout("con");
  cout.rdbuf(conout.rdbuf()); 
  cerr.rdbuf(conout.rdbuf());      
  cin.rdbuf(conin.rdbuf());


  FreeConsole();
  return 0;
}

edit: , ++, ++/cli

+1

Source: https://habr.com/ru/post/1739481/


All Articles