PfCreateInterface returns 错误 120(未实现)

PfCreateInterface returns error 120 (not implemented)

我需要为 Windows 创建一个简单的 IP 过滤程序;但是,我在使相关的 API 调用工作时遇到问题。下面是一个小例子,展示了 PfCreateInterface 是如何失败的。它返回 120,这是系统错误代码 ERROR_CALL_NOT_IMPLEMENTED。我是运行Windows10.

的节目
#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 吗?

Microsoft's documentation 很清楚:

PfCreateInterface is available for use in the operating systems listed in the Requirements section.

Windows 版本 "listed in the Requirements section" 是 Windows Server 2003 或 Windows 2000 Server。

所以这个 API 调用基本上已经过时了。文档建议改用 the Windows Filtering Platform management functions