GiacomoLaw / Keylogger

A simple keylogger for Windows, Linux and Mac
https://simple-keylogger.github.io/
MIT License
2.09k stars 616 forks source link

Compilation error using x86_64-w64-mingw32-c++.exe #110

Closed resis10ce closed 3 years ago

resis10ce commented 3 years ago

Hi, i am using mingw c++ compiler for compiling klog_main but i got this error. i am unable to get thee issue

x86_64-w64-mingw32-c++.exe ../klog_main.cpp ../klog_main.cpp: In function 'void SetHook()': ../klog_main.cpp:56:26: error: cannot convert 'LPCWSTR' {aka 'const wchar_t'} to 'LPCSTR' {aka 'const char'} MessageBox(NULL, a, b, MB_ICONERROR);

In file included from C:/tools/Delet/mingw64/x86_64-w64-mingw32/include/Windows.h:72, from ../klog_main.cpp:1: C:/tools/Delet/mingw64/x86_64-w64-mingw32/include/winuser.h:3566:54: note: initializing argument 2 of 'int MessageBoxA(HWND, LPCSTR, LPCSTR, UINT)' WINUSERAPI int WINAPI MessageBoxA(HWND hWnd,LPCSTR lpText,LPCSTR lpCaption,UINT uType);
Screenshot 2021-05-30 110007

bartoszluka commented 3 years ago

@resis10ce I managed to fix that by explicitly casting to LPCSTR. Replace line 56 (the one throwing an error) with this

MessageBox(NULL, (LPCSTR)a, (LPCSTR)b, MB_ICONERROR);

then try to compile it the the same way you did. It worked for me.