Hi, I am modifying a small application in c ++ that allows me to take control of my mouse and my keyboard, the code is as follows:
#include <windows.h>
#include <conio.h>
#include <stdio.h>
int main()
{
HINSTANCE hDLL = LoadLibraryW (L"user32.dll");
if (hDLL == NULL)
{
fprintf (stderr, "Failed to load user32.dll, error code %d\n", GetLastError());
return 1;
}
typedef BOOL (WINAPI *BLOCKINPUT)(BOOL);
BLOCKINPUT pBlockInput;
pBlockInput = (BLOCKINPUT)GetProcAddress (hDLL, "BlockInput");
if (pBlockInput == NULL)
{
fprintf (stderr, "Failed to import BlockInput, error code %d\n", GetLastError());
FreeLibrary(hDLL);
return 1;
}
else
{
BOOL res = pBlockInput (TRUE);
if (!res) {
fprintf (stderr, "BlockInput failed, error code %d\n", GetLastError());
}
Sleep (20);
}
FreeLibrary(hDLL);
_getch();
}
The problem esque goes directly to the if it seems that the res variable is always false so I can not do what I'm trying:
What I want is that basically with blockinput for a while nobody can use my keyboard and mouse.