2009-08-02 1 views
3
MSDN 당으로

을 제공 비슷한 일이, http://msdn.microsoft.com/en-us/library/ms646302%28VS.85%29.aspxGetLastInputInfo 사용자 고유 - 기계 전반의 마지막 입력 시간

GetLastInputInfo 실행중인 모든 세션에 걸쳐 시스템 전체 사용자 입력 정보 를 제공하지 않습니다. 오히려 GetLastInputInfo는 이 해당 세션을 호출 한 세션에 대해서만 세션 별 사용자 입력 정보를 제공합니다.

비슷한 시스템상의 최종 사용자 입력 정보가 ​​있습니까?

답변

2

이 작업을 수행하는 유일한 방법은 셸에 연결하는 것입니다.

이것은 (분명히)주의 깊게해야하며 운영 체제 (Windows 7이 아닐 때까지)에서 완전히 지원되기 전까지는 관리 코드에서 실현 가능하지 않은 무언가입니다. 따라서 관리되지 않는 코드를 사용해야합니다. 아마도 관리 코드에서 질의 가능한 일부 전역 상태를 업데이트 할 것입니다. 이 API는 SetWindowsHookEx입니다.

Vista의 세션 분리로 인해 다른 세션에서이 작업을 수행하려면 승격 된 권한이 필요합니다. 키로거의 작동 방식에 대한 단서가 도움이 될지 모르지만 이에 대한 몇 가지 출처에 대한 준비 링크가 없습니다.

/*************************************************************** 
* 
* Copyright (C) 1990-2007, Condor Team, Computer Sciences Department, 
* University of Wisconsin-Madison, WI. 
* 
* Licensed under the Apache License, Version 2.0 (the "License"); you 
* may not use this file except in compliance with the License. You may 
* obtain a copy of the License at 
* 
* http://www.apache.org/licenses/LICENSE-2.0 
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed under the License is distributed on an "AS IS" BASIS, 
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License. 
* 
***************************************************************/ 


#include <windows.h> 

// Shared DATA 
// put in here data that is needed globally 
#pragma data_seg(".SHARDATA") 
HHOOK hHook = NULL; 
LONG KBkeyhitflag = 0; 
#pragma data_seg() 
#pragma comment(linker, "/SECTION:.SHARDATA,RWS") 

__declspec(dllexport) LRESULT CALLBACK KBHook(int nCode, WPARAM wParam, 
LPARAM lParam) 
{ 
    InterlockedExchange(&KBkeyhitflag,1); 

    return CallNextHookEx(hHook,nCode,wParam,lParam); 
} 

HINSTANCE g_hinstDLL = NULL; 

#if defined(__cplusplus) 
extern "C" { 
#endif //__cplusplus 


int __declspec(dllexport) WINAPI KBInitialize(void) 
{ 
    hHook=(HHOOK)SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KBHook,g_hinstDLL,0); 
    return hHook ? 1 : 0; 
} 

int __declspec(dllexport) WINAPI KBShutdown(void) 
{ 
    if (UnhookWindowsHookEx(hHook)) 
     return 1; // success 
    else 
     return 0; // failure 
} 

int __declspec(dllexport) WINAPI KBQuery(void) 
{ 
    if (InterlockedExchange(&KBkeyhitflag,0)) 
     return 1; // a key has been hit since last query 
    else 
     return 0; // no keys hit since asked last 
} 

#if defined(__cplusplus) 
} // extern "C" 
#endif //defined(__cplusplus) 

BOOL WINAPI DllMain(HANDLE hInstDLL, ULONG fdwReason, LPVOID lpReserved) 
{ 
    switch (fdwReason) 
    { 
     case DLL_PROCESS_ATTACH: 
      g_hinstDLL = (HINSTANCE)hInstDLL; 
      DisableThreadLibraryCalls(g_hinstDLL); 
      break; 
    } 
    return 1; 
} 
: 여기에 첫 번째 시작으로

는 안보 키보드 활동에 대한 condor의 창 포트에서 근원이다
관련 문제