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