Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Win32 Api在C++;失败_C++_Windows_Winapi_Device_Createfile - Fatal编程技术网

C++ Win32 Api在C++;失败

C++ Win32 Api在C++;失败,c++,windows,winapi,device,createfile,C++,Windows,Winapi,Device,Createfile,以下代码在一台电脑上工作,但在另一台电脑上不工作。这两台电脑的操作系统都是Windows 7 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 = G

以下代码在一台电脑上工作,但在另一台电脑上不工作。这两台电脑的操作系统都是Windows 7

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");
}
成功打开文件的PC的输出:

device_name: \\.\interception00
GetLastError (Number): 0, error == ERROR_SUCCESS
另一台电脑无法打开该文件。输出为:

device_name: \\.\interception00
GetLastError (Number): 2, error == ERROR_FILE_NOT_FOUND 
有人知道为什么会这样吗?可能是权限不足的问题?

来自MSDN:

打开现有的\u

仅当文件或设备存在时才打开该文件或设备

如果指定的文件或设备不存在,则函数将失败,最后一个错误代码将设置为error_file_not_FOUND(2)

这意味着一台计算机上存在
\\.\\interception00
,而另一台计算机上不存在。尝试使用通常能够打开文件/设备的其他程序进行查看

或者修复
\\\.\\interception00
不可用的问题。

来自MSDN:

打开现有的\u

仅当文件或设备存在时才打开该文件或设备

如果指定的文件或设备不存在,则函数将失败,最后一个错误代码将设置为error_file_not_FOUND(2)

这意味着一台计算机上存在
\\.\\interception00
,而另一台计算机上不存在。尝试使用通常能够打开文件/设备的其他程序进行查看


或者修复
\\.\\interception00
不可用的问题。

可能第二台计算机没有运行创建该设备特殊文件的驱动程序。您的错误检查有些虚假。仅当API调用失败时才调用GetLastError。您没有检查故障。可能第二台计算机没有运行创建该设备特殊文件的驱动程序。您的错误检查有些虚假。仅当API调用失败时才调用GetLastError。你不检查故障。你知道监视所有可用设备的方法/工具吗?我不知道。很抱歉其他人?我现在知道了。这是一个名为WinObj:)的软件,你知道如何修复\\\\.\\interception00是可保存的吗?我甚至不知道这个特殊文件的用途(特殊文件可以用于任何用途),而且网上也没有关于interception00的信息。提供此路径的另一台计算机上有一个驱动程序。你也需要在第二台计算机上安装该软件。如果你不知道那是哪个软件,那么我建议(1)你使用代理ransack搜索整个硬盘,寻找“拦截”,如果你没有找到哪个软件提供了拦截00,那么用grepWin搜索整个硬盘试试同样的方法。你知道一种方法/工具来监视所有可用的设备吗?我不知道。很抱歉其他人?我现在知道了。这是一个名为WinObj:)的软件,你知道如何修复\\\\.\\interception00是可保存的吗?我甚至不知道这个特殊文件的用途(特殊文件可以用于任何用途),而且网上也没有关于interception00的信息。提供此路径的另一台计算机上有一个驱动程序。你也需要在第二台计算机上安装该软件。如果你不知道那是哪种软件,我建议(1)你使用代理ransack搜索整个硬盘,寻找“拦截”,如果你没有找到哪种软件提供了拦截00,那么尝试使用grepWin搜索整个硬盘。