2014-03-01 09:32:23 +04:00
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/error.h>
|
|
|
|
#include <winpr/wtsapi.h>
|
|
|
|
|
2015-02-10 20:05:40 +03:00
|
|
|
int TestWtsApiExtraVirtualChannel(int argc, char* argv[])
|
2014-03-01 09:32:23 +04:00
|
|
|
{
|
|
|
|
BOOL bSuccess;
|
|
|
|
ULONG length;
|
|
|
|
ULONG bytesRead;
|
|
|
|
ULONG bytesWritten;
|
|
|
|
BYTE buffer[1024];
|
|
|
|
HANDLE hVirtualChannel;
|
|
|
|
|
|
|
|
length = sizeof(buffer);
|
|
|
|
|
2015-02-10 20:05:40 +03:00
|
|
|
hVirtualChannel = WTSVirtualChannelOpen(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, "sample");
|
2014-03-01 09:32:23 +04:00
|
|
|
|
2015-02-10 20:05:40 +03:00
|
|
|
if (hVirtualChannel == INVALID_HANDLE_VALUE)
|
2014-03-01 09:32:23 +04:00
|
|
|
{
|
|
|
|
printf("WTSVirtualChannelOpen failed: %d\n", (int) GetLastError());
|
2015-02-10 20:05:40 +03:00
|
|
|
return -1;
|
2014-03-01 09:32:23 +04:00
|
|
|
}
|
2015-02-10 20:05:40 +03:00
|
|
|
printf("WTSVirtualChannelOpen opend");
|
2014-03-01 09:32:23 +04:00
|
|
|
bytesWritten = 0;
|
|
|
|
bSuccess = WTSVirtualChannelWrite(hVirtualChannel, (PCHAR) buffer, length, &bytesWritten);
|
|
|
|
|
|
|
|
if (!bSuccess)
|
|
|
|
{
|
|
|
|
printf("WTSVirtualChannelWrite failed: %d\n", (int) GetLastError());
|
2015-02-10 20:05:40 +03:00
|
|
|
return -1;
|
2014-03-01 09:32:23 +04:00
|
|
|
}
|
2015-02-10 20:05:40 +03:00
|
|
|
printf("WTSVirtualChannelWrite written");
|
2014-03-01 09:32:23 +04:00
|
|
|
|
|
|
|
bytesRead = 0;
|
|
|
|
bSuccess = WTSVirtualChannelRead(hVirtualChannel, 5000, (PCHAR) buffer, length, &bytesRead);
|
|
|
|
|
|
|
|
if (!bSuccess)
|
|
|
|
{
|
|
|
|
printf("WTSVirtualChannelRead failed: %d\n", (int) GetLastError());
|
2015-02-10 20:05:40 +03:00
|
|
|
return -1;
|
2014-03-01 09:32:23 +04:00
|
|
|
}
|
2015-02-10 20:05:40 +03:00
|
|
|
printf("WTSVirtualChannelRead read");
|
2014-03-01 09:32:23 +04:00
|
|
|
|
|
|
|
if (!WTSVirtualChannelClose(hVirtualChannel))
|
|
|
|
{
|
|
|
|
printf("WTSVirtualChannelClose failed\n");
|
2015-02-10 20:05:40 +03:00
|
|
|
return -1;
|
2014-03-01 09:32:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|