handling session change notifications

git-svn-id: http://apu.dw.local/svnusers/JoshHoltrop/pppc/trunk@37 8131a0b2-b21c-1c47-bd6a-f003126495bd
This commit is contained in:
joshholtrop 2009-07-29 22:16:46 +00:00
parent dde23b5594
commit a62a75386f

37
pppc.cc
View File

@ -76,9 +76,13 @@ int WinMain(
cerr << "Warning: Shell_NotifyIcon(): " << GetLastError() << endl; cerr << "Warning: Shell_NotifyIcon(): " << GetLastError() << endl;
} }
/* begin capturing session notifications */
session_notification_enable(hWnd);
BOOL bRet; BOOL bRet;
MSG msg; MSG msg;
for (;;) bool running = true;
while(running)
{ {
bRet = GetMessage(&msg, NULL, 0, 0); bRet = GetMessage(&msg, NULL, 0, 0);
if (bRet == -1 || bRet == 0) if (bRet == -1 || bRet == 0)
@ -93,21 +97,48 @@ int WinMain(
case WM_COMMAND: case WM_COMMAND:
cerr << "WM_COMMAND" << endl; cerr << "WM_COMMAND" << endl;
break; break;
case WM_CLOSE:
case WM_DESTROY:
case WM_QUIT:
running = false;
break;
case WM_WTSSESSION_CHANGE:
if (msg.wParam == WTS_SESSION_LOGON
|| msg.wParam == WTS_SESSION_UNLOCK)
{
pport_write(0xFF);
}
if (msg.wParam == WTS_SESSION_LOGOFF
|| msg.wParam == WTS_SESSION_LOCK)
{
pport_write(0x0);
}
break;
} }
} }
/* stop listening for session notifications */
session_notification_disable(hWnd);
return bRet; return bRet;
} }
LRESULT WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
cerr << "WindowProc()" << endl;
switch (message) switch (message)
{ {
case WM_NCCREATE: case WM_NCCREATE:
return 1; return 1;
case WM_CREATE: case WM_CREATE:
cerr << "WindowProc(): WM_CREATE" << endl; break;
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_ICON_NOTIFY:
cerr << "WM_ICON_NOTIFY" << endl;
break; break;
} }
return 0; return 0;