installed pty
[VSoRC/.git] / node_modules / node-pty / deps / winpty / misc / Win32Test1.cc
1 #define _WIN32_WINNT 0x0501
2 #include "../src/shared/DebugClient.cc"
3 #include <windows.h>
4 #include <stdio.h>
5
6 const int SC_CONSOLE_MARK = 0xFFF2;
7
8 CALLBACK DWORD writerThread(void*)
9 {
10     while (true) {
11         Sleep(1000);
12         trace("writing");
13         printf("X\n");
14         trace("written");
15     }
16 }
17
18 int main()
19 {
20     CreateThread(NULL, 0, writerThread, NULL, 0, NULL);
21     trace("marking console");
22     HWND hwnd = GetConsoleWindow();
23     PostMessage(hwnd, WM_SYSCOMMAND, SC_CONSOLE_MARK, 0);
24
25     Sleep(2000);
26
27     trace("reading output");
28     CHAR_INFO buf[1];
29     COORD bufSize = { 1, 1 };
30     COORD zeroCoord = { 0, 0 };
31     SMALL_RECT readRect = { 0, 0, 0, 0 };
32     ReadConsoleOutput(GetStdHandle(STD_OUTPUT_HANDLE),
33                       buf,
34                       bufSize,
35                       zeroCoord,
36                       &readRect);
37     trace("done reading output");
38
39     Sleep(2000);
40
41     PostMessage(hwnd, WM_CHAR, 27, 0x00010001);
42
43     Sleep(1100);
44
45     return 0;
46 }