Skip to content

Commit

Permalink
Remove "Press any key to continue" pause after target application exited
Browse files Browse the repository at this point in the history
  • Loading branch information
crosire committed Aug 7, 2016
1 parent 8a1806b commit 4ad8d08
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,6 @@ inline void _initterm(_PVFV *beg, _PVFV *end)

HANDLE console = INVALID_HANDLE_VALUE;

void pause()
{
DWORD mode;
const HANDLE console = GetStdHandle(STD_INPUT_HANDLE);

if (!GetConsoleMode(console, &mode) || !SetConsoleMode(console, 0))
{
return;
}

FlushConsoleInputBuffer(console);

INPUT_RECORD input;

do
{
DWORD count;
ReadConsoleInput(console, &input, 1, &count);
}
while (input.EventType != KEY_EVENT || input.Event.KeyEvent.bKeyDown);

SetConsoleMode(console, mode);
}
void print(const char *message, size_t length)
{
DWORD size = static_cast<DWORD>(length);
Expand Down Expand Up @@ -241,18 +218,17 @@ int main(int argc, char *argv[])
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), message, size, &size, nullptr);
}

DWORD exitcode = 0;
DWORD exitcode = 0, remote_exitcode = 0;
GetExitCodeThread(remote_thread, &exitcode);
GetExitCodeProcess(remote_process, &remote_exitcode);

// Clean up handles
CloseHandle(local_pipe);
CloseHandle(remote_thread);
CloseHandle(remote_process);

// Exit
std::cout << "The target application has exited. Press any key to continue ..." << std::endl;

pause();
std::cout << "The target application has exited with code " << remote_exitcode << "." << std::endl;

return static_cast<int>(exitcode);
}

0 comments on commit 4ad8d08

Please sign in to comment.