2014-03-01 09:32:23 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/error.h>
|
|
|
|
#include <winpr/wtsapi.h>
|
2016-05-30 18:54:59 +03:00
|
|
|
#include <winpr/environment.h>
|
2014-03-01 09:32:23 +04:00
|
|
|
|
|
|
|
int TestWtsApiShutdownSystem(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
BOOL bSuccess;
|
|
|
|
HANDLE hServer;
|
|
|
|
DWORD ShutdownFlag;
|
|
|
|
|
2016-05-30 18:54:59 +03:00
|
|
|
#ifndef _WIN32
|
|
|
|
if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", NULL, 0))
|
|
|
|
{
|
|
|
|
printf("%s: No RDS environment detected, skipping test\n", __FUNCTION__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-01 09:32:23 +04:00
|
|
|
hServer = WTS_CURRENT_SERVER_HANDLE;
|
|
|
|
ShutdownFlag = WTS_WSD_SHUTDOWN;
|
|
|
|
|
|
|
|
bSuccess = WTSShutdownSystem(hServer, ShutdownFlag);
|
|
|
|
|
|
|
|
if (!bSuccess)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("WTSShutdownSystem failed: %"PRIu32"\n", GetLastError());
|
2016-05-30 18:54:59 +03:00
|
|
|
return -1;
|
2014-03-01 09:32:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|