2014-03-18 05:37:12 +04:00
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/wnd.h>
|
2014-05-22 21:50:01 +04:00
|
|
|
#include <winpr/tchar.h>
|
2014-03-19 00:39:43 +04:00
|
|
|
#include <winpr/wtsapi.h>
|
2014-03-18 22:43:25 +04:00
|
|
|
#include <winpr/library.h>
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
const char* WM_WTS_STRINGS[] = { "",
|
|
|
|
"WTS_CONSOLE_CONNECT",
|
|
|
|
"WTS_CONSOLE_DISCONNECT",
|
|
|
|
"WTS_REMOTE_CONNECT",
|
|
|
|
"WTS_REMOTE_DISCONNECT",
|
|
|
|
"WTS_SESSION_LOGON",
|
|
|
|
"WTS_SESSION_LOGOFF",
|
|
|
|
"WTS_SESSION_LOCK",
|
|
|
|
"WTS_SESSION_UNLOCK",
|
|
|
|
"WTS_SESSION_REMOTE_CONTROL",
|
|
|
|
"WTS_SESSION_CREATE",
|
|
|
|
"WTS_SESSION_TERMINATE",
|
|
|
|
"" };
|
2014-03-18 22:43:25 +04:00
|
|
|
|
2014-03-19 02:03:55 +04:00
|
|
|
static LRESULT CALLBACK TestWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2014-03-19 00:39:43 +04:00
|
|
|
{
|
2014-03-18 22:43:25 +04:00
|
|
|
switch (uMsg)
|
|
|
|
{
|
2014-03-19 00:39:43 +04:00
|
|
|
case WM_WTSSESSION_CHANGE:
|
|
|
|
if (wParam && (wParam < 13))
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
PWTSSESSION_NOTIFICATION pNotification = (PWTSSESSION_NOTIFICATION)lParam;
|
2014-03-19 00:39:43 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("WM_WTSSESSION_CHANGE: %s SessionId: %" PRIu32 "\n", WM_WTS_STRINGS[wParam],
|
|
|
|
(int)pNotification->dwSessionId);
|
2014-03-19 00:39:43 +04:00
|
|
|
}
|
2014-03-18 22:43:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("TestWndProc: uMsg: 0x%08" PRIX32 "\n", uMsg);
|
2014-03-18 22:43:25 +04:00
|
|
|
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
2014-03-19 00:39:43 +04:00
|
|
|
break;
|
2014-03-18 22:43:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-03-18 05:37:12 +04:00
|
|
|
|
|
|
|
int TestWndCreateWindowEx(int argc, char* argv[])
|
|
|
|
{
|
2014-03-18 22:43:25 +04:00
|
|
|
HWND hWnd;
|
|
|
|
HMODULE hModule;
|
|
|
|
HINSTANCE hInstance;
|
|
|
|
WNDCLASSEX wndClassEx;
|
2014-03-19 00:39:43 +04:00
|
|
|
WTSSESSION_NOTIFICATION wtsSessionNotification;
|
2014-03-18 22:43:25 +04:00
|
|
|
|
|
|
|
hModule = GetModuleHandle(NULL);
|
|
|
|
|
|
|
|
ZeroMemory(&wndClassEx, sizeof(WNDCLASSEX));
|
|
|
|
wndClassEx.cbSize = sizeof(WNDCLASSEX);
|
|
|
|
wndClassEx.style = 0;
|
|
|
|
wndClassEx.lpfnWndProc = TestWndProc;
|
|
|
|
wndClassEx.cbClsExtra = 0;
|
|
|
|
wndClassEx.cbWndExtra = 0;
|
|
|
|
wndClassEx.hInstance = hModule;
|
|
|
|
wndClassEx.hIcon = NULL;
|
|
|
|
wndClassEx.hCursor = NULL;
|
|
|
|
wndClassEx.hbrBackground = NULL;
|
|
|
|
wndClassEx.lpszMenuName = _T("TestWndMenu");
|
|
|
|
wndClassEx.lpszClassName = _T("TestWndClass");
|
|
|
|
wndClassEx.hIconSm = NULL;
|
|
|
|
|
|
|
|
if (!RegisterClassEx(&wndClassEx))
|
|
|
|
{
|
|
|
|
printf("RegisterClassEx failure\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
hInstance = wndClassEx.hInstance;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
hWnd = CreateWindowEx(0, wndClassEx.lpszClassName, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hInstance,
|
|
|
|
NULL);
|
2014-03-18 22:43:25 +04:00
|
|
|
|
|
|
|
if (!hWnd)
|
|
|
|
{
|
|
|
|
printf("CreateWindowEx failure\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-19 00:39:43 +04:00
|
|
|
wtsSessionNotification.cbSize = sizeof(WTSSESSION_NOTIFICATION);
|
|
|
|
wtsSessionNotification.dwSessionId = 123;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
SendMessage(hWnd, WM_WTSSESSION_CHANGE, WTS_SESSION_LOGON, (LPARAM)&wtsSessionNotification);
|
2014-03-19 00:39:43 +04:00
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
2014-03-18 22:43:25 +04:00
|
|
|
|
2014-03-18 05:37:12 +04:00
|
|
|
return 0;
|
|
|
|
}
|