키로거 프로그램을 작성하고 있습니다. 내 프로그램에서, 현재 활성화 된 윈도우 제목을 로그 파일에 기록하고 싶습니다. 그리고 사용자가 다른 창으로 변경하면 로그 파일에 새 제목 창이 추가됩니다. 여기에 Windows 제목을 얻는 코드가 있습니다.C# - 현재 창 제목 얻기
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern int GetWindowText(IntPtr hwnd, string lpString, int cch);
public static string ActiveApplTitle()
{
//This method is used to get active application's title using GetWindowText() method present in user32.dll
IntPtr hwnd = GetForegroundWindow();
if (hwnd.Equals(IntPtr.Zero)) return "";
string lpText = new string((char)0, 100);
int intLength = GetWindowText(hwnd, lpText, lpText.Length);
if ((intLength <= 0) || (intLength > lpText.Length)) return "unknown";
return lpText.Trim();
}
변경 사항이있을 때 창 제목을 업데이트하는 방법을 모르겠습니다. 제게 아이디어를주십시오. 고마워요!
'키로거 작성 중 '---> 행운을 빌어 여기를 –
'GetWindowText'를 다시 호출 할 수 있도록 창 제목이 변경되면 알림을 받고 싶습니까? –
맬웨어 작성 요청은 offtopic입니다. – MatthewMartin