FreeRDP
TestWtsApiShutdownSystem.c
1 #include <winpr/crt.h>
2 #include <winpr/error.h>
3 #include <winpr/wtsapi.h>
4 #include <winpr/environment.h>
5 
6 int TestWtsApiShutdownSystem(int argc, char* argv[])
7 {
8  BOOL bSuccess = 0;
9  HANDLE hServer = NULL;
10  DWORD ShutdownFlag = 0;
11 
12  WINPR_UNUSED(argc);
13  WINPR_UNUSED(argv);
14 
15 #ifndef _WIN32
16  if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", NULL, 0))
17  {
18  printf("%s: No RDS environment detected, skipping test\n", __func__);
19  return 0;
20  }
21 #endif
22 
23  hServer = WTS_CURRENT_SERVER_HANDLE;
24  ShutdownFlag = WTS_WSD_SHUTDOWN;
25 
26  bSuccess = WTSShutdownSystem(hServer, ShutdownFlag);
27 
28  if (!bSuccess)
29  {
30  printf("WTSShutdownSystem failed: %" PRIu32 "\n", GetLastError());
31  return -1;
32  }
33 
34  return 0;
35 }