2014-03-18 05:37:12 +04:00
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/wnd.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 00:39:43 +04:00
|
|
|
LRESULT CALLBACK TestWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
printf("WM_WTSSESSION_CHANGE: %s SessionId: %d\n",
|
|
|
|
WM_WTS_STRINGS[wParam], (int) pNotification->dwSessionId);
|
|
|
|
}
|
2014-03-18 22:43:25 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-03-19 00:39:43 +04:00
|
|
|
printf("TestWndProc: uMsg: 0x%04X\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-19 00:39:43 +04:00
|
|
|
//MSG msg;
|
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;
|
|
|
|
}
|
|
|
|
|