1. 程式人生 > >記錄一些有用的API(一)

記錄一些有用的API(一)

switch(message)
 {
  case WM_WTSSESSION_CHANGE:
   {
switch(wParam)
   {
   case WTS_CONSOLE_CONNECT:
    MessageBox("WTS_CONSOLE_CONNECT", "Esmile", MB_OK );
    break;
   case WTS_CONSOLE_DISCONNECT:
    MessageBox("WTS_CONSOLE_DISCONNECT",
    "Esmile", MB_OK );
    break;
   case WTS_SESSION_LOCK:
    MessageBox("WTS_SESSION_LOCK",
    "Esmile", MB_OK );
    break;
   case WTS_SESSION_UNLOCK:
    MessageBox("WTS_SESSION_UNLOCK",
    "Esmile", MB_OK );
    break;
   case WTS_SESSION_LOGOFF:
    MessageBox("WTS_SESSION_LOGOFF",
    "Esmile", MB_OK );
    break;
   case WTS_SESSION_LOGON:
    MessageBox("WTS_SESSION_LOGON",
    "Esmile", MB_OK );
    break;
   default:
    break;
   }
}
   break;
default:
   break;
 }

五.WTSGetActiveConsoleSessionId

得到當前登入使用者的會話ID

DWORD WTSGetActiveConsoleSessionId(void);

六.ProcessIdToSessionId

根據程序ID獲取SessionId
DWORD a=WTSGetActiveConsoleSessionId();
DWORD b=0;
ProcessIdToSessionId(GetCurrentProcessId(),&b);
a==b;

七.POWERBROADCAST_SETTING

當在WM_POWERBROADCAST訊息中捕獲訊息時可以轉化成這個結構體