I have a device that acts like a HID (keyboard). I was able to capture and grab the raw input of the device on Linux. I needed to get exclusive rights to the device so that no other application could receive input from it. I accomplished this using ioctl and EVIOCGRAB

But it doesn't compile under Windows. I have found that there is a RegisterRawInputDevices function but it doesn't seem to provide exclusive rights to the device. What could be used on Windows to achieve the same effect?


Here is my code that works on Linux

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <dirent.h>
#include <linux/input.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/select.h>
#include <sys/time.h>
#include <termios.h>
#include <signal.h>


int main(int argc, char* argv[])
{
    struct input_event ev[64];
    int fevdev = -1;
    int result = 0;
    int size = sizeof(struct input_event);
    int rd;
    int value;
    char name[256] = "Unknown";
    char *device = "/dev/input/event16";


    fevdev = open(device, O_RDONLY);
    ioctl(fevdev, EVIOCGRAB, 1);


    while (1)
    {
        read(fevdev, ev, size * 64);
        value = ev[0].value;
        printf ("code - %d \n", ev[1].code);
    }


    ioctl(fevdev, EVIOCGRAB, 0);
    close(fevdev);
}