我需要为 Windows 创建一个简单的 IP 过滤程序;但是,我在使相关的 API 调用正常工作时遇到了问题。下面是一个小示例,演示了 PfCreateInterface
是如何失败的。它返回 120
,这是系统错误代码 ERROR_CALL_NOT_IMPLEMENTED
。我在 Windows 10 上运行该程序。
#include <windows.h>
#include <Iphlpapi.h>
#include <Fltdefs.h>
#include <iostream>
#pragma comment(lib, "Iphlpapi.lib")
int main()
{
INTERFACE_HANDLE hInterface;
PFFORWARD_ACTION action = PF_ACTION_FORWARD;
DWORD errorCode = PfCreateInterface(0,
action,
action,
FALSE,
TRUE,
&hInterface);
std::cout << "errorCode = " << errorCode << std::endl;
}
有人可以解释为什么它失败了吗?如果我不能在 Windows 10 上使用它,您知道替代 API 是什么吗?
最佳答案
PfCreateInterface is available for use in the operating systems listed in the Requirements section.
“要求部分中列出的”Windows 版本是 Windows Server 2003 或 Windows 2000 Server。
所以这个 API 调用基本上已经过时了。文档建议使用 the Windows Filtering Platform management functions相反。
关于c++ - PfCreateInterface 返回错误 120(未实现),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58559521/