编程实现将自己的网络程序放入windows防火墙"例外"tab page之中程序列表内3Q!

解决方案 »

  1.   

    ^_^,还真的有INetFwMgr Interface
    http://msdn.microsoft.com/en-us/library/aa365287(VS.85).aspx
      

  2.   

    HRESULT IsPortAllowed(
      [in]   BSTR imageFileName,
      [in]   NET_FW_IP_VERSION ipVersion,
      [in]   LONG portNumber,
      [in]   BSTR localAddress,
      [in]   NET_FW_IP_PROTOCOL ipProtocol,
      [out]  VT_BOOL *allowed,
      [out]  VT_BOOL *restricted
    );ParametersimageFileName [in]    The image file name of the process listening on the network. It must be a fully-qualified path, but may contain environment variables. If imageFileName is NULL, the function determines whether the port is allowed for all applications.
    ipVersion [in]    IP version of the traffic. If localAddress is non-NULL, this must not be NET_FW_IP_VERSION_ANY.
    portNumber [in]    Local IP port number of the traffic.
    localAddress [in]    Either a dotted-decimal IPv4 address or an IPv6 hex address specifying the local address of the traffic. Typically, this is the address passed to bind. If localAddress is NULL, the function determines whether the port is allowed for all interfaces.
    ipProtocol [in]    IP protocol of the traffic, either NET_FW_IP_PROTOCOL_TCP or NET_FW_IP_PROTOCOL_UDP.
    allowed [out]    Indicates by a value of VARIANT_TRUE or VARIANT_FALSE whether the port is allowed for at least some local interfaces and remote addresses.
    restricted [out]    Indicates by a value of VARIANT_TRUE or VARIANT_FALSE whether some local interfaces or remote addresses are blocked for this port. For example, if the port is restricted to the local subnet only.Return ValueIf the method succeeds the return value is S_OK.If the method fails, the return value is one of the following error codes.