PeerGroupJoin function (p2p.h)

The PeerGroupJoin function prepares a peer with an invitation to join an existing peer group prior to calling PeerGroupConnect or PeerGroupConnectByAddress.


  [in]  PCWSTR pwzIdentity,
  [in]  PCWSTR pwzInvitation,
  [in]  PCWSTR pwzCloud,
  [out] HGROUP *phGroup


[in] pwzIdentity

Pointer to a Unicode string that contains the identity opening the specified peer group. If this parameter is NULL, the implementation uses the identity obtained from PeerIdentityGetDefault.

[in] pwzInvitation

Pointer to a Unicode string that contains the XML invitation granted by another peer. An invitation is created when the inviting peer calls PeerGroupCreateInvitation or PeerGroupIssueCredentials. Specific details regarding this invitation can be obtained as a PEER_INVITATION_INFO structure by calling PeerGroupParseInvitation. This parameter is required.

[in] pwzCloud

Pointer to a Unicode string that contains the name of the PNRP cloud where a group is located. The default value is NULL, which indicates that the cloud specified in the invitation must be used.

[out] phGroup

Pointer to the handle of the peer group. To start communication with a group, call PeerGroupConnect. 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 available to complete the operation.
The cloud cannot be uniquely discovered, for example, more than one cloud matches the provided name.
The peer identity specified in pwzIdentity is invalid.
The validity period specified in the invitation is invalid. Either the specified period has expired or the invitation is not yet valid (i.e. the specified ValidityStart date\time has not yet been reached). One possible reason for the return of this error is that the system clock is incorrectly set on the machine joining the group, or on the machine that issued the invitation.
The invitation is not trusted. This may be due to invitation alteration, errors, or expiration.
The cloud cannot be located.
The invitation is not supported by the current version of the Peer Infrastructure.
Access to the peer identity or peer 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 has been reset manually.

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


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