| 199 | } |
| 200 | |
| 201 | void waitForKeyPressedUnderWindows() |
| 202 | { |
| 203 | #if defined(_WIN32) |
| 204 | HANDLE hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); |
| 205 | |
| 206 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 207 | if (!GetConsoleScreenBufferInfo(hStdOutput, &csbi)) { |
| 208 | printf("GetConsoleScreenBufferInfo failed: %lu\n", GetLastError()); |
| 209 | return; |
| 210 | } |
| 211 | |
| 212 | /* do not pause when running on a shell */ |
| 213 | if (csbi.dwCursorPosition.X != 0 || csbi.dwCursorPosition.Y != 0) |
| 214 | return; |
| 215 | |
| 216 | /* only pause if running in separate console window. */ |
| 217 | printf("\n\tPress any key to exit...\n"); |
| 218 | _getch(); |
| 219 | #endif |
| 220 | } |
| 221 | |
| 222 | |
| 223 | /* -------------------------------------------------------------------------- */ |