3 #include <winpr/error.h>
4 #include <winpr/wtsapi.h>
6 int TestWtsApiExtraVirtualChannel(
int argc,
char* argv[])
12 char buffer[1024] = { 0 };
13 const size_t length =
sizeof(buffer);
15 HANDLE hVirtualChannel =
16 WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION,
"sample");
18 if (hVirtualChannel == INVALID_HANDLE_VALUE)
20 printf(
"WTSVirtualChannelOpen failed: %" PRIu32
"\n", GetLastError());
23 printf(
"WTSVirtualChannelOpen opend");
24 ULONG bytesWritten = 0;
25 BOOL bSuccess = WTSVirtualChannelWrite(hVirtualChannel, buffer, length, &bytesWritten);
29 printf(
"WTSVirtualChannelWrite failed: %" PRIu32
"\n", GetLastError());
32 printf(
"WTSVirtualChannelWrite written");
35 bSuccess = WTSVirtualChannelRead(hVirtualChannel, 5000, buffer, length, &bytesRead);
39 printf(
"WTSVirtualChannelRead failed: %" PRIu32
"\n", GetLastError());
42 printf(
"WTSVirtualChannelRead read");
44 if (!WTSVirtualChannelClose(hVirtualChannel))
46 printf(
"WTSVirtualChannelClose failed\n");