summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp
blob: eab3275a38b6477447280201026c736bff6d1439 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0


#include <windows.h>

int APIENTRY WinMain(HINSTANCE /* hInstance */,
                     HINSTANCE /* hPrevInstance */,
                     LPSTR     /* lpCmdLine */,
                     int       /* nCmdShow */)
{

    HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
    HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);

    HANDLE hStderr = GetStdHandle(STD_ERROR_HANDLE);

    for (;;) {

        char c = 0;
        DWORD read = 0;
        if (!ReadFile(hStdin, &c, 1, &read, 0) || read == 0 || c == 'q' || c == '\0')
            break;
        DWORD wrote = 0;
        WriteFile(hStdout, &c, 1, &wrote, 0);
        WriteFile(hStderr, &c, 1, &wrote, 0);
    }
    return 0;
}