PeerGroupCreate function (p2p.h)

The PeerGroupCreate function creates a new peer group.


  [in]  PPEER_GROUP_PROPERTIES pProperties,
  [out] HGROUP                 *phGroup


[in] pProperties

Pointer to a PEER_GROUP_PROPERTIES structure that specifies the specific details of the group, such as the peer group names, invitation lifetimes, and presence lifetimes. This parameter is required.

The following members must be set:

  • pwzCreatorPeerName

The following members cannot be set:

  • pwzGroupPeerName
The remaining members are optional.

[out] phGroup

Returns the handle pointer to the peer group. Any function called with this handle as a parameter has the corresponding action performed on that peer group. This parameter is required.

Return value

Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.

Return code Description
One of the parameters is not valid.
There is not enough memory to perform the specified operation.
The cloud specified in pProperties cannot be uniquely discovered (more than one cloud matches the provided name).
The peer group classifier specified in pProperties is invalid.
The peer name specified for the group in pProperties is invalid.
One or more of the peer group properties supplied in pProperties is invalid.
The cloud specified in pProperties cannot be located.
Access to the identity or group keys is denied. Typically, this is caused by an incorrect access control list (ACL) for the folder that contains the user or computer keys. This can happen when the ACL is reset manually.
Password specified does not meet system password requirements.
The peer identity specified as the Group Creator has been deleted or is in the process of being deleted.

Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and defined in Winerror.h.


PeerGroupConnect must be called by the group creator immediately after creation. If this does not take place, users given an invitation will call PeerGroupConnect successfully but they will not be able to listen and will eventually receive the connection failed event.

An application obtains an identity by calling PeerIdentityCreate, or any other method that returns an identity name string. This identity serves as the owner of the group, and is the initial member of the peer group when created.

For applications that utilize passwords, it is recommended the passwords are handled securely by calling the CryptoProtectMemory and SecureZeroMemory functions.


Minimum supported client Windows XP with SP2 [desktop apps only],Windows XP with SP1 with the Advanced Networking Pack forWindows XP
Minimum supported server None supported
Target Platform Windows
Header p2p.h
Library P2P.lib
DLL P2P.dll

See also