Share via


Creating and Deleting a Peer Identity (Windows CE 5.0)

Send Feedback

The Identity Manager allows you to create and delete peer identities that are used in a peer-to-peer network. When you create a peer identity, you can provide the following information:

  • The Classifier part of a peer name
  • The friendly name
  • A cryptographic service provider

Note   Whenever it is possible, re-use a peer identity.

To create a peer identity, use the PeerIdentityCreate function. The following code example shows a CreateIdentity function that creates a peer identity by using a classifier and friendly name.

/-------------------------------------------------------------------------
// Function: CreateIdentity
// Purpose: Creates a new Identity.
// Returns: HRESULT
//------------------------------------------------------------------------
HRESULT CreateIdentity(PWSTR pwzFriendlyName)
{
  HRESULT  hr = S_OK;
  PWSTR  pwzClassifier = L"GroupMember";
  PWSTR  pwzIdentity = NULL;
  hr = PeerIdentityCreate(pwzClassifier, pwzFriendlyName, 0, &pwzIdentity);
  if (FAILED(hr))
  {
    printf("Failed to create identity.");
  }
  else
  {
    printf("Identity: %s", pwzFriendlyName);
  }
  PeerFreeData(pwzIdentity);
  return hr;
}

To delete an existing peer identity, use the PeerIdentityDelete function. The following example code shows a DeleteIdentity function that deletes a peer identity created by CreateIdentity.

//------------------------------------------------------------------------
// Function: DeleteIdentity
// Purpose:  Delete the identity created by CreateIdentity
// Returns:  HRESULT
//------------------------------------------------------------------------
HRESULT DeleteIdentity()
{
  HRESULT hr = S_OK;
  if (g_pwzIdentity)
  {
    hr = PeerIdentityDelete(g_pwzIdentity);
    g_pwzIdentity = NULL;
  }
  return hr;
}

See Also

Peer-to-Peer Application Development

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.