UNPKG

1.18 kBtext/x-cView Raw
1#include <windows.h>
2
3#include <stdio.h>
4#include <stdlib.h>
5
6#include "TestUtil.cc"
7
8int main(int argc, char *argv[]) {
9 if (argc != 5) {
10 printf("Usage: %s x y width height\n", argv[0]);
11 return 1;
12 }
13
14 const HANDLE conout = CreateFileW(L"CONOUT$",
15 GENERIC_READ | GENERIC_WRITE,
16 FILE_SHARE_READ | FILE_SHARE_WRITE,
17 NULL, OPEN_EXISTING, 0, NULL);
18 ASSERT(conout != INVALID_HANDLE_VALUE);
19
20 SMALL_RECT sr = {
21 (short)atoi(argv[1]),
22 (short)atoi(argv[2]),
23 (short)(atoi(argv[1]) + atoi(argv[3]) - 1),
24 (short)(atoi(argv[2]) + atoi(argv[4]) - 1),
25 };
26
27 trace("Calling SetConsoleWindowInfo with {L=%d,T=%d,R=%d,B=%d}",
28 sr.Left, sr.Top, sr.Right, sr.Bottom);
29 BOOL ret = SetConsoleWindowInfo(conout, TRUE, &sr);
30 const unsigned lastError = GetLastError();
31 const char *const retStr = ret ? "OK" : "failed";
32 trace("SetConsoleWindowInfo ret: %s (LastError=0x%x)", retStr, lastError);
33 printf("SetConsoleWindowInfo ret: %s (LastError=0x%x)\n", retStr, lastError);
34
35 return 0;
36}