FreeRDP/winpr/libwinpr/wtsapi/test/TestWtsApiExtraVirtualChannel.c

54 lines
1.2 KiB
C
Raw Normal View History

#include <winpr/crt.h>
#include <winpr/error.h>
#include <winpr/wtsapi.h>
int TestWtsApiExtraVirtualChannel(int argc, char* argv[])
{
BOOL bSuccess;
ULONG length;
ULONG bytesRead;
ULONG bytesWritten;
BYTE buffer[1024];
HANDLE hVirtualChannel;
length = sizeof(buffer);
2019-11-06 17:24:51 +03:00
hVirtualChannel =
WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, "sample");
if (hVirtualChannel == INVALID_HANDLE_VALUE)
{
2019-11-06 17:24:51 +03:00
printf("WTSVirtualChannelOpen failed: %" PRIu32 "\n", GetLastError());
return -1;
}
printf("WTSVirtualChannelOpen opend");
bytesWritten = 0;
2019-11-06 17:24:51 +03:00
bSuccess = WTSVirtualChannelWrite(hVirtualChannel, (PCHAR)buffer, length, &bytesWritten);
if (!bSuccess)
{
2019-11-06 17:24:51 +03:00
printf("WTSVirtualChannelWrite failed: %" PRIu32 "\n", GetLastError());
return -1;
}
printf("WTSVirtualChannelWrite written");
bytesRead = 0;
2019-11-06 17:24:51 +03:00
bSuccess = WTSVirtualChannelRead(hVirtualChannel, 5000, (PCHAR)buffer, length, &bytesRead);
if (!bSuccess)
{
2019-11-06 17:24:51 +03:00
printf("WTSVirtualChannelRead failed: %" PRIu32 "\n", GetLastError());
return -1;
}
printf("WTSVirtualChannelRead read");
if (!WTSVirtualChannelClose(hVirtualChannel))
{
printf("WTSVirtualChannelClose failed\n");
return -1;
}
return 0;
}