記錄一些有用的API(一)
阿新 • • 發佈:2019-02-02
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獲取SessionIdDWORD a=WTSGetActiveConsoleSessionId();
DWORD b=0;
ProcessIdToSessionId(GetCurrentProcessId(),&b);
a==b;