The following code is working under one PC but not on an other PC. Both PC's have Windows 7 as their OS.
char device_name[] = "\\\\.\\interception00";
printf("device_name: %s \n", device_name);
device_array[i].handle = CreateFile(device_name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
DWORD error = GetLastError();
printf("GetLastError (Number): %d, ", error);
if (error == ERROR_FILE_NOT_FOUND)
{
printf("error == ERROR_FILE_NOT_FOUND \n");
}
else if (error == ERROR_SUCCESS)
{
printf("error == ERROR_SUCCESS \n");
}
else
{
printf("error == UNBEKANNT \n");
}
The Output of the PC that is successfully opens the File:
device_name: \\.\interception00
GetLastError (Number): 0, error == ERROR_SUCCESS
The other PC is not able to open the File. The Output is:
device_name: \\.\interception00
GetLastError (Number): 2, error == ERROR_FILE_NOT_FOUND
Does someone have a clue why this happens ? Maybe it is a problem of insufficient rights ?
GetLastErrorif the API call fails. You don't check for failure. - David Heffernan