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>
|
|
|
|
|
2014-03-19 00:39:43 +04:00
|
|
|
const char* WM_WTS_STRINGS[] =
|
2014-03-18 22:43:25 +04:00
|
|
|
{
|
2014-03-19 00:39:43 +04:00
|
|
|
"",
|
|
|
|
"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))
|
|
|
|
{
|
|
|
|
PWTSSESSION_NOTIFICATION pNotification = (PWTSSESSION_NOTIFICATION) lParam;
|
|
|
|
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("WM_WTSSESSION_CHANGE: %s SessionId: %"PRIu32"\n",
|
2014-03-19 00:39:43 +04:00
|
|
|
WM_WTS_STRINGS[wParam], (int) pNotification->dwSessionId);
|
|
|
|
}
|
2014-03-18 22:43:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-12-14 00:47:08 +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;
|
|
|
|
|
|
|
|
hWnd = CreateWindowEx(0, wndClassEx.lpszClassName,
|
|
|
|
0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hInstance, NULL);
|
|
|
|
|
|
|
|
if (!hWnd)
|
|
|
|
{
|
|
|
|
printf("CreateWindowEx failure\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-03-19 00:39:43 +04:00
|
|
|
wtsSessionNotification.cbSize = sizeof(WTSSESSION_NOTIFICATION);
|
|
|
|
wtsSessionNotification.dwSessionId = 123;
|
|
|
|
|
|
|
|
SendMessage(hWnd, WM_WTSSESSION_CHANGE, WTS_SESSION_LOGON, (LPARAM) &wtsSessionNotification);
|
|
|
|
|
|
|
|
DestroyWindow(hWnd);
|
2014-03-18 22:43:25 +04:00
|
|
|
|
2014-03-18 05:37:12 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|