为什么我收到“无法找到类型或命名空间名称'LowLevelKeyboardProc'”?

时间:2013-06-05 19:12:58

标签: c# visual-studio console-application

using以下内容:

using System;
using System.Diagnostics;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;

我在这里收到错误: private static LowLevelKeyboardProc _proc = HookCallback;

和此处:[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);

我正在使用VS2012 w / C#并遵循本教程:http://null-byte.wonderhowto.com/how-to/create-simple-hidden-console-keylogger-c-sharp-0132757/

1 个答案:

答案 0 :(得分:3)

您需要定义委托。您引用的文章使用:

private delegate IntPtr LowLevelKeyboardProc(
    int nCode, IntPtr wParam, IntPtr lParam);

这包含在the referenced article的“第3步”中。