67fb97f68f
Move wtsapi tests that only make sense when run within a session ("interactive") to TestWtsApiExtra since they either brake automated builds or don't make sense if the return value isn't checked. TestWtsApiExtra is not build by default but can be enabled by specifying -DTESTS_WTSAPI_EXTRA=ON (this option is only available if BUILD_TESTING is enabled). The tests set the ctest label WTSAPI_EXTRA and can therefore also be run explicitly with ctest -L WTSAPI_EXTRA.
55 lines
1.2 KiB
C
55 lines
1.2 KiB
C
|
|
#include <winpr/crt.h>
|
|
#include <winpr/error.h>
|
|
#include <winpr/wtsapi.h>
|
|
|
|
int TestWtsApiExtraDynamicVirtualChannel(int argc, char* argv[])
|
|
{
|
|
BOOL bSuccess;
|
|
ULONG length;
|
|
ULONG bytesRead;
|
|
ULONG bytesWritten;
|
|
BYTE buffer[1024];
|
|
HANDLE hVirtualChannel;
|
|
|
|
length = sizeof(buffer);
|
|
|
|
hVirtualChannel = WTSVirtualChannelOpenEx( WTS_CURRENT_SESSION, "ECHO",WTS_CHANNEL_OPTION_DYNAMIC);
|
|
|
|
|
|
if (hVirtualChannel == INVALID_HANDLE_VALUE)
|
|
{
|
|
printf("WTSVirtualChannelOpen failed: %d\n", (int) GetLastError());
|
|
return -1;
|
|
}
|
|
printf("WTSVirtualChannelOpen opend");
|
|
bytesWritten = 0;
|
|
bSuccess = WTSVirtualChannelWrite(hVirtualChannel, (PCHAR) buffer, length, &bytesWritten);
|
|
|
|
if (!bSuccess)
|
|
{
|
|
printf("WTSVirtualChannelWrite failed: %d\n", (int) GetLastError());
|
|
return -1;
|
|
}
|
|
printf("WTSVirtualChannelWrite written");
|
|
|
|
bytesRead = 0;
|
|
bSuccess = WTSVirtualChannelRead(hVirtualChannel, 5000, (PCHAR) buffer, length, &bytesRead);
|
|
|
|
if (!bSuccess)
|
|
{
|
|
printf("WTSVirtualChannelRead failed: %d\n", (int) GetLastError());
|
|
return -1;
|
|
}
|
|
printf("WTSVirtualChannelRead read");
|
|
|
|
if (!WTSVirtualChannelClose(hVirtualChannel))
|
|
{
|
|
printf("WTSVirtualChannelClose failed\n");
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|