Process.Start() ing exe 不起作用

Process.Start() ing exe doesn't work

我正在使用以下代码行来启动我制作的键盘记录器:

ProcessStartInfo keylogger = new ProcessStartInfo(@"C:\keylogger.exe");
keylogger.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(keylogger);

当我使用此代码时,键盘记录器启动但不记录任何击键。我以为这是因为试图隐藏进程window,所以我将代码更改为:

ProcessStartInfo keylogger = new ProcessStartInfo(@"C:\keylogger.exe");
Process.Start(keylogger);

还是一样的问题,我什至单独试过Process.Start(@"C:\keylogger.exe");,但似乎还是不行。

在所有情况下,键盘记录器都会启动,但不会将任何击键记录到日志文件中。但是,如果我双击并打开键盘记录器,它就可以正常工作了。

请参阅本页 "To send a keystroke to a different application":

http://msdn.microsoft.com/en-us/library/ms171548.aspx

您的主要问题是您的按键记录器应用程序不是 运行 应用程序,因此它无法捕获所有按键...

为了获得所有应用程序的击键,您需要挂接到系统内核,请查看以下内容 http://www.codeproject.com/Articles/6362/Global-System-Hooks-in-NET

牢记:

System hooks are powerful. And, with that power comes responsibility. When something goes wrong with system hooks, they don't just break your application. They can break every application running on your system. It is unlikely that it would actually come to that extreme. Nonetheless, you need to double and triple check your code when using system hooks.

看来我所要做的就是更改工作目录..lol!

此代码有效:

ProcessStartInfo keylogger = new ProcessStartInfo(@"C:\keylogger.exe");
keylogger.WorkingDirectory = @"C:\";
keylogger.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(keylogger);