How to minimize the console window?

I run a console application in C ++, for some period of time,
I want to minimize the window in which my application runs. For example, for. I am running myApp.exe from cmd. Then it was launched in a new window.
So, which libraries can minimize the window in which the application runs.
The application does not have a graphical interface

+4
source share
2 answers

I assume that your application runs on Windows (this is not portable for different operating systems).

GetConsoleWindow(), ShowWindow(), / . windows.h:

ShowWindow(GetConsoleWindow(), SW_MINIMIZE);

SW_MINIMIZE SW_HIDE, ( ).

, , DETACHED_PROCESS: . CreateProcess() , (, ...)

UPDATE: Windows, , , , AllocConsole:

if (AllocConsole()) {
    printf("Now I can print to console...\n");
    FreeConsole();
}
+8

-

... | | | |

Windows. WinMain(), :

  int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  { int argc = 0;
    LPWSTR* argv = CommandLineToArgvW(GetCommandLine(), &argc);    
    return Main(argc, argv);
  }

unicode. , wmain() Main(), . , printf .

+1

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


All Articles