FreeRDP
TestWtsApiExtraStartRemoteSessionEx.c
1 
2 #include <winpr/crt.h>
3 #include <winpr/error.h>
4 #include <winpr/wtsapi.h>
5 #include <winpr/input.h>
6 #include <winpr/environment.h>
7 
8 int TestWtsApiExtraStartRemoteSessionEx(int argc, char* argv[])
9 {
10  WINPR_UNUSED(argc);
11  WINPR_UNUSED(argv);
12 
13  ULONG logonId = 0;
14  char logonIdStr[10] = { 0 };
15 
16  DWORD bSuccess = GetEnvironmentVariableA("TEST_SESSION_LOGON_ID", logonIdStr, 10);
17  if (bSuccess > 0)
18  {
19  sscanf(logonIdStr, "%u\n", &logonId);
20  }
21 
22  bSuccess = WTSStartRemoteControlSessionEx(
23  NULL, logonId, VK_F10, REMOTECONTROL_KBDSHIFT_HOTKEY | REMOTECONTROL_KBDCTRL_HOTKEY,
24  REMOTECONTROL_FLAG_DISABLE_INPUT);
25 
26  if (!bSuccess)
27  {
28  printf("WTSStartRemoteControlSessionEx failed: %" PRIu32 "\n", GetLastError());
29  return -1;
30  }
31 
32  return 0;
33 }