3 #include <winpr/error.h>
4 #include <winpr/wtsapi.h>
6 int TestWtsApiExtraDynamicVirtualChannel(
int argc,
char* argv[])
11 HANDLE hVirtualChannel =
12 WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION,
"ECHO", WTS_CHANNEL_OPTION_DYNAMIC);
14 if (hVirtualChannel == INVALID_HANDLE_VALUE)
16 printf(
"WTSVirtualChannelOpen failed: %" PRIu32
"\n", GetLastError());
19 printf(
"WTSVirtualChannelOpen opend");
20 ULONG bytesWritten = 0;
21 char buffer[1024] = { 0 };
22 size_t length =
sizeof(buffer);
23 BOOL bSuccess = WTSVirtualChannelWrite(hVirtualChannel, buffer, length, &bytesWritten);
27 printf(
"WTSVirtualChannelWrite failed: %" PRIu32
"\n", GetLastError());
30 printf(
"WTSVirtualChannelWrite written");
33 bSuccess = WTSVirtualChannelRead(hVirtualChannel, 5000, (PCHAR)buffer, length, &bytesRead);
37 printf(
"WTSVirtualChannelRead failed: %" PRIu32
"\n", GetLastError());
40 printf(
"WTSVirtualChannelRead read");
42 if (!WTSVirtualChannelClose(hVirtualChannel))
44 printf(
"WTSVirtualChannelClose failed\n");