INetFwRules::Add method (netfw.h)

The Add method adds a new rule to the collection.

Syntax

HRESULT Add(
  [in] INetFwRule *rule
);

Parameters

[in] rule

Rule to be added to the collection via an INetFwRule object.

Return value

C++

If the method succeeds the return value is S_OK.

If the method fails, the return value is one of the following error codes.

Return code Description
E_ACCESSDENIED
The operation was aborted due to permissions issues.
E_INVALIDARG
The method failed because a parameter was not valid.
E_UNEXPECTED
The method failed because the object is already in the collection.
 

VB

If the method succeeds the return value is S_OK.

If the method fails, the return value is one of the following error codes.

Return code Description
E_ACCESSDENIED
The operation was aborted due to permissions issues.
E_INVALIDARG
The method failed because a parameter was not valid.
E_UNEXPECTED
The method failed because the object is already in the collection.

Remarks

If a rule with the same rule identifier as the one being submitted already exists, the existing rule is overwritten.

Adding a firewall rule with a LocalAppPackageId specified can lead to unexpected behavior and is not supported.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header netfw.h
DLL FirewallAPI.dll

See also

INetFwRule

INetFwRules