Last active
March 1, 2018 22:30
-
-
Save mojocorp/d1a0b400abd790f44a53 to your computer and use it in GitHub Desktop.
Windows winmain argc argv console application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _WIN32 | |
#include <windows.h> | |
#include <stdio.h> | |
#pragma warning(disable: 4996) | |
extern int main(int argc, char* argv[]); | |
int WINAPI WinMain(HINSTANCE /*hInstance*/, | |
HINSTANCE /*hPrevInstance*/, | |
LPSTR /*lpCmdLine*/, | |
int /*nCmdShow*/) | |
{ | |
// Redirect stdin, stdout, stderr to the console. | |
if (AttachConsole(ATTACH_PARENT_PROCESS)) { | |
freopen("CONIN$", "r", stdin); | |
freopen("CONOUT$", "w", stdout); | |
freopen("CONOUT$", "w", stderr); | |
} | |
return main(__argc, __argv); | |
} | |
#endif //_WIN32 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment