-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathwinsta.cpp
35 lines (28 loc) · 1.09 KB
/
winsta.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <objbase.h>
#include <stdio.h>
#pragma comment(lib, "winsta.lib")
extern "C"
{
BOOL WinStationPreCreateGlassReplacementSession(LPCWSTR lpwszInitialCommand, DWORD dwConnectTimeout, DWORD* lpdwSessionId); // dwReconnectTargetId == -1
BOOL WinStationPreCreateGlassReplacementSessionEx(LPCWSTR lpwszInitialCommand, DWORD dwReconnectTargetId, DWORD dwConnectTimeout, DWORD* lpdwSessionId);
BOOL WinStationTerminateGlassReplacementSession(DWORD dwSessionId);
}
int main()
{
DWORD dwSessionId = 0;
if (!WinStationPreCreateGlassReplacementSession(L"%SYSTEMROOT%\\System32\\WinLogon.exe -SpecialSession", 0, &dwSessionId))
{
fwprintf(stderr, L"WinStationPreCreateGlassReplacementSession(), GetLastError() = %u\n", GetLastError());
return 1;
}
wprintf(L"dwSessionId = %u\n", dwSessionId);
system("pause");
if (!WinStationTerminateGlassReplacementSession(dwSessionId))
{
fwprintf(stderr, L"WinStationTerminateGlassReplacementSession(), GetLastError() = %u\n", GetLastError());
return 1;
}
return 0;
}