[ create a new paste ] login | about

Link: http://codepad.org/VI01xYwf    [ raw code | output | fork ]

C++, pasted on Sep 7:
#include<iostream>
#include<Windows.h>

using namespace std;

HHOOK kHook = NULL;

LRESULT CALLBACK _keyboard_proc(int ncode, WPARAM wparam, LPARAM lparam)
{
	cout << "hit a key" << endl;

	return CallNextHookEx(kHook, ncode, wparam, lparam);
}

int main(void)
{
	kHook = SetWindowsHookEx(WH_KEYBOARD_LL, reinterpret_cast<HOOKPROC>(_keyboard_proc), GetModuleHandle(NULL), NULL);

	if (!kHook)
		cout << "set hook fail" << endl;

	MSG msg;

	while (GetMessage(&msg, NULL, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return 0;
}


Output:
1
2
3
Line 19: error: Windows.h: No such file or directory
Line 6: error: 'HHOOK' does not name a type
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: