Share via


FirewallCreateRule

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

This function creates a new firewall rule.

Aa922338.security(en-us,MSDN.10).gifSecurity Note:
The IP Firewall handles fragments in a manner that helps to prevent attacks on the private host stack. Do not add a rule to allow traffic to a host if the host's stack does not support these defense mechanisms. The following list shows these defense mechanisms:
  • If no rule allows traffic to the packet destination, the firewall blocks fragments to that destination.
  • If a fragment contains a transport layer header, the firewall drops the fragment.

Syntax

DWORD FirewallCreateRule(
  FW_RULE* pRule, 
  BOOL bPersist
);

Parameters

  • pRule
    [out] Pointer to the FW_RULE structure that specifies the rule to create.
  • bPersist
    [in] TRUE to save the rule in the registry so that it is preserved when a reboot occurs. Specify FALSE if the rule is not saved.

Return Value

Returns ERROR_SUCCESS if operation succeeds.

Remarks

On success, this function sets HRULE to the rule handle for this new rule.

Requirements

Header fwapi.h
Library fwapi.lib
Windows Embedded CE Windows CE .NET 4.2 and later

See Also

Reference

IP Firewall Functions

Other Resources

System Errors - Alphabetical Order