using System;
using System.Runtime.InteropServices;
using Vanara.InteropServices;
namespace Vanara.PInvoke
{
/// Items from the P2P.dll
public static partial class P2P
{
/// The PeerCollabAddContact function adds a contact to the contact list of a peer.
///
///
/// Pointer to a zero-terminated Unicode string buffer that contains the contact data for the peer that is added to the contact
/// list. This string buffer can either be obtained by passing the peer name of the endpoint to add as a contact to
/// PeerCollabQueryContactData, or through an out-of-band mechanism.
///
///
/// To send its own contact data out-of-band, the peer can call PeerCollabExportContact with a NULL peer name. This function
/// returns the contact data in XML format.
///
///
///
///
/// Pointer to a pointer to a PEER_CONTACT structure. This parameter receives the address of a PEER_CONTACT structure
/// containing peer contact information for the contact supplied in pwzContactData. This parameter may be NULL.
///
/// Call PeerFreeData on the address of the PEER_CONTACT structure to free this data.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabaddcontact NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabAddContact( PCWSTR pwzContactData, PPEER_CONTACT *ppContact );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabAddContact")]
public static extern HRESULT PeerCollabAddContact([MarshalAs(UnmanagedType.LPWStr)] string pwzContactData,
//[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_CONTACT ppContact);
out SafePeerData ppContact);
///
/// The PeerCollabAsyncInviteContact function sends an invitation to a trusted peer contact to join the sender's peer
/// collaboration activity over a secured connection. The availability of the invitation response is updated through an asynchronous event.
///
///
///
/// Pointer to a PEER_CONTACT structure that contains the contact information associated with the recipient of the invite. This
/// parameter is optional.
///
/// To invite the endpoint of the calling peer specified in pcEndpoint, set the pointer value to NULL.
///
///
/// Pointer to a PEER_ENDPOINT structure that contains information about the invited peer's endpoint. The endpoint must be
/// associated with the peer contact specified in pcContact.
///
///
/// Pointer to a PEER_INVITATION structure that contains the invitation request to send to the endpoint specified in pcEndpoint.
/// E_INVALIDARG is returned if this parameter is set to NULL.
///
///
///
/// Handle to the event for this invitation, created by a previous call to CreateEvent. The event is signaled when the status of the
/// asynchronous invitation is updated. To obtain the response data, call PeerCollabGetInvitationResponse.
///
/// If the event is not provided the caller must poll for the result by calling PeerCollabGetInvitationResponse.
///
///
/// A pointer to a handle to the sent invitation. The framework will cleanup the response information after the invitation response
/// is received if NULL is specified. When NULL is not the specified handle to the invitation provided, it must be
/// closed by calling PeerCollabCloseHandle.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// E_NOTIMPL
/// pcEndpoint is NULL.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
///
///
/// This API ensures the peer that receives the invitation is the contact specified as input. The connection will fail if the
/// specific contact is not present on the endpoint specified. The use of PeerCollabAsyncInviteContact is recommended in
/// place of the less secure PeerCollabAsyncInviteEndpoint.
///
///
/// A toast will appear for the recipient of the invitation. This toast will be converted to a dialog box in which the user can
/// accept or decline the invitation. When the invitation is successfully accepted, the collaborative application is launched on the
/// recipient's machine.
///
///
/// To successfully receive the invitation the application must be registered on the recipient's machine using
/// PeerCollabRegisterApplication. It is also possible for the sender of the invite to have failure codes returned because the
/// recipient has turned off application invites.
///
///
/// The PeerCollabGetInvitiationResponse function will return PEER_E_CONNECTION_FAILED if the contact to which the invitation is
/// being sent is not accepting invitations.
///
///
/// If the recipient is accepting invitations only from trusted contacts, then the sender of the invite must be added to the contact
/// store of the recipient machine. The sender must be added to the contact store before the invitation attempt. To add a contact to
/// the contact store, call PeerCollabAddContact.
///
/// To cancel an outstanding invitation, call PeerCollabCancelInvitation.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabasyncinvitecontact NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabAsyncInviteContact( PCPEER_CONTACT pcContact, PCPEER_ENDPOINT pcEndpoint, PCPEER_INVITATION pcInvitation, HANDLE
// hEvent, HANDLE *phInvitation );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabAsyncInviteContact")]
public static extern HRESULT PeerCollabAsyncInviteContact(in PEER_CONTACT pcContact, in PEER_ENDPOINT pcEndpoint, in PEER_INVITATION pcInvitation, [In, Optional] HANDLE hEvent, out SafePeerCollabHandle phInvitation);
///
/// The PeerCollabAsyncInviteContact function sends an invitation to a trusted peer contact to join the sender's peer
/// collaboration activity over a secured connection. The availability of the invitation response is updated through an asynchronous event.
///
///
///
/// Pointer to a PEER_CONTACT structure that contains the contact information associated with the recipient of the invite. This
/// parameter is optional.
///
/// To invite the endpoint of the calling peer specified in pcEndpoint, set the pointer value to NULL.
///
///
/// Pointer to a PEER_ENDPOINT structure that contains information about the invited peer's endpoint. The endpoint must be
/// associated with the peer contact specified in pcContact.
///
///
/// Pointer to a PEER_INVITATION structure that contains the invitation request to send to the endpoint specified in pcEndpoint.
/// E_INVALIDARG is returned if this parameter is set to NULL.
///
///
///
/// Handle to the event for this invitation, created by a previous call to CreateEvent. The event is signaled when the status of the
/// asynchronous invitation is updated. To obtain the response data, call PeerCollabGetInvitationResponse.
///
/// If the event is not provided the caller must poll for the result by calling PeerCollabGetInvitationResponse.
///
///
/// A pointer to a handle to the sent invitation. The framework will cleanup the response information after the invitation response
/// is received if NULL is specified. When NULL is not the specified handle to the invitation provided, it must be
/// closed by calling PeerCollabCloseHandle.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// E_NOTIMPL
/// pcEndpoint is NULL.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
///
///
/// This API ensures the peer that receives the invitation is the contact specified as input. The connection will fail if the
/// specific contact is not present on the endpoint specified. The use of PeerCollabAsyncInviteContact is recommended in
/// place of the less secure PeerCollabAsyncInviteEndpoint.
///
///
/// A toast will appear for the recipient of the invitation. This toast will be converted to a dialog box in which the user can
/// accept or decline the invitation. When the invitation is successfully accepted, the collaborative application is launched on the
/// recipient's machine.
///
///
/// To successfully receive the invitation the application must be registered on the recipient's machine using
/// PeerCollabRegisterApplication. It is also possible for the sender of the invite to have failure codes returned because the
/// recipient has turned off application invites.
///
///
/// The PeerCollabGetInvitiationResponse function will return PEER_E_CONNECTION_FAILED if the contact to which the invitation is
/// being sent is not accepting invitations.
///
///
/// If the recipient is accepting invitations only from trusted contacts, then the sender of the invite must be added to the contact
/// store of the recipient machine. The sender must be added to the contact store before the invitation attempt. To add a contact to
/// the contact store, call PeerCollabAddContact.
///
/// To cancel an outstanding invitation, call PeerCollabCancelInvitation.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabasyncinvitecontact NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabAsyncInviteContact( PCPEER_CONTACT pcContact, PCPEER_ENDPOINT pcEndpoint, PCPEER_INVITATION pcInvitation, HANDLE
// hEvent, HANDLE *phInvitation );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabAsyncInviteContact")]
public static extern HRESULT PeerCollabAsyncInviteContact([In, Optional] IntPtr pcContact, in PEER_ENDPOINT pcEndpoint, in PEER_INVITATION pcInvitation, [In, Optional] HANDLE hEvent, out SafePeerCollabHandle phInvitation);
///
/// The PeerCollabAsyncInviteEndpoint function sends an invitation to a specified peer endpoint to join the sender's peer
/// collaboration activity. The availability of the response to the invitation is updated through an asynchronous event.
///
///
///
/// Pointer to a PEER_ENDPOINT structure that contains information about the invited peer. This peer is sent an invitation when this
/// API is called.
///
/// This parameter must not be set to NULL.
///
///
/// Pointer to a PEER_INVITATION structure that contains the invitation request to send to the endpoint specified in pcEndpoint.
/// E_INVALIDARG is returned if this parameter is set to NULL.
///
///
///
/// Handle to the event for this invitation, created by a previous call to CreateEvent. The event is signaled when the status of the
/// asynchronous invitation is updated. To obtain the response data, call PeerCollabGetInvitationResponse.
///
/// If the event is not provided, the caller must poll for the result by calling PeerCollabGetInvitationResponse.
///
///
/// A pointer to a handle to the sent invitation. If this parameter is NULL, the framework will cleanup the response
/// information after the invitation response is received. If this parameter is not NULL, the handle must be closed by
/// calling PeerCollabCloseHandle.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
///
///
///
///
/// This API sends an invitation to the endpoint specified as input. It does not guarantee that the recipient of the invite is the
/// specific contact that the user intended to send the invite to. To ensure that the invitation is sent to the correct contact use PeerCollabAsyncInviteContact.
///
///
/// A toast will appear for the recipient of the invitation. This toast will be converted to a dialog box in which the user can
/// accept or decline the invitation. When the invitation is successfully accepted, the collaborative application is launched on the
/// recipient's machine.
///
///
/// To successfully receive the invitation, the application must be registered on the recipient's machine using
/// PeerCollabRegisterApplication. It is also possible for the sender of the invite to have failure codes returned because the
/// recipient has turned off application invites.
///
///
/// The PeerCollabGetInvitiationResponse function will return PEER_E_CONNECTION_FAILED if the endpoint to which the invitation is
/// being sent is not accepting invitations.
///
///
/// If the recipient is accepting invitations only from trusted contacts, then the sender of the invite must be added to the contact
/// store of the recipient machine. The sender must be added to the contact store before the invitation attempt. To add a contact to
/// the contact store, call PeerCollabAddContact.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabasyncinviteendpoint NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabAsyncInviteEndpoint( PCPEER_ENDPOINT pcEndpoint, PCPEER_INVITATION pcInvitation, HANDLE hEvent, HANDLE *phInvitation );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabAsyncInviteEndpoint")]
public static extern HRESULT PeerCollabAsyncInviteEndpoint(in PEER_ENDPOINT pcEndpoint, in PEER_INVITATION pcInvitation, [In, Optional] HANDLE hEvent, out SafePeerCollabHandle phInvitation);
/// The PeerCollabCancelInvitation function cancels an invitation previously sent by the caller to a contact.
/// Handle to a previously sent invitation.
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// The provided handle is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The application did not make a previous call to PeerCollabStartup.
///
/// -
/// E_HANDLE
/// The handle specified is invalid.
///
///
///
///
///
/// When PeerCollabCancelInvitation is called, depending on the state of the invitation, it will perform one or more of the
/// following actions:
///
///
/// -
///
/// If the connection to the receiver is not yet established, it will cancel the connection creation process and the receiver will
/// not see the invitation.
///
///
/// -
///
/// If the invitation has been received, but not responded to, it will notify the recipient contact that the invitation has been
/// canceled. As a result, the receiver will not be able to respond to the invitation.
///
///
/// -
///
/// If the receiver has already responded to the invitation, the call performs a no-op. After canceling the invitation, you must
/// call PeerCollabCloseHandle.
///
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabcancelinvitation NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabCancelInvitation( HANDLE hInvitation );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabCancelInvitation")]
public static extern HRESULT PeerCollabCancelInvitation([In] SafePeerCollabHandle hInvitation);
/// The PeerCollabCloseHandle function closes the handle to a Peer Collaboration activity invitation.
/// Handle obtained by a previous call to PeerCollabAsyncInviteContact or PeerCollabAsyncInviteEndpoint.
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_HANDLE
/// The handle specified is invalid.
///
///
///
///
/// You must call this API after the handle has been signaled for an event and any data associated with the event has been obtained.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabclosehandle NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabCloseHandle( HANDLE hInvitation );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabCloseHandle")]
public static extern HRESULT PeerCollabCloseHandle(HANDLE hInvitation);
/// The PeerCollabDeleteContact function deletes a contact from the local contact store associated with the caller.
///
/// Pointer to a zero-terminated Unicode string that contains the peer name of the contact to delete. This parameter must not be
/// NULL. You cannot delete the 'Me' contact.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
///
///
///
/// Once a contact is deleted using PeerCollabDeleteContact, the presence updates provided by a subscription will no longer
/// be available for that contact. If the contact is being watched (fWatch is set to TRUE) than PEER_EVENT_WATCHLIST_CHANGED
/// will be raised.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabdeletecontact NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabDeleteContact( PCWSTR pwzPeerName );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabDeleteContact")]
public static extern HRESULT PeerCollabDeleteContact([MarshalAs(UnmanagedType.LPWStr)] string pwzPeerName);
///
/// The PeerCollabDeleteEndpointData function deletes the peer endpoint data on the calling peer node that matches the
/// supplied endpoint data.
///
///
/// Pointer to a PEER_ENDPOINT structure that contains the peer endpoint information to delete from the current peer node.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
///
///
///
/// The function PeerCollabDeleteEndpointData is used to remove cached endpoint data previously retrieved by
/// PeerCollabRefreshEndpointData when it is no longer required. Any data obtained through PeerCollabRefreshEndpointData
/// remains in memory until PeerCollabDeleteEndpointData is called.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabdeleteendpointdata NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabDeleteEndpointData( PCPEER_ENDPOINT pcEndpoint );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabDeleteEndpointData")]
public static extern HRESULT PeerCollabDeleteEndpointData(in PEER_ENDPOINT pcEndpoint);
/// The PeerCollabDeleteObject function deletes a peer object from the calling endpoint.
/// Pointer to a GUID value that uniquely identifies the peer object to delete from the calling endpoint.
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// The operation requires the user to be signed in.
///
///
///
///
///
/// Peer objects are run-time data items associated with a particular application, such as a picture, an avatar, a certificate, or a
/// specific description. Each peer object must be smaller than 3216K in size.
///
///
/// Trusted contacts watching this peer object and the subscriber of the "Me" contact will have a PEER_EVENT_OBJECT_CHANGED event
/// raised, signaling this peer object's change in status. PEER_EVENT_MY_OBJECT_CHANGED will be raised locally.
///
/// Pre-defined objects, like Picture objects, cannot be deleted by calling this API.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabdeleteobject NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabDeleteObject( const GUID *pObjectId );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabDeleteObject")]
public static extern HRESULT PeerCollabDeleteObject(in Guid pObjectId);
///
/// The PeerCollabEnumApplicationRegistrationInfo function obtains the enumeration handle used to retrieve peer application information.
///
///
/// A PEER_APPLICATION_REGISTRATION_TYPE value that specifies whether the peer's application is registered to the current
/// user or all users of the peer's machine.
///
///
/// Pointer to a peer enumeration handle for the peer application registration information. This data is obtained by passing this
/// handle to PeerGetNextItem.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
///
///
/// To obtain the individual peer applications, pass the returned handle to PeerGetNextItem. An array of
/// PEER_APPLICATION_REGISTRATION_INFO structures will be returned. To close the enumeration and release the resources associated
/// with it, pass this handle to PeerEndEnumeration. Individual items returned by the enumeration must be released with PeerFreeData.
///
///
/// An application is a set of software or software features available on the peer's endpoint. Commonly, this refers to software
/// packages that support peer networking activities, like games or other collaborative applications.
///
///
/// A peer's application has a GUID representing a single specific application. When an application is registered for a peer, this
/// GUID and the corresponding application can be made available to all trusted contacts of the peer, indicating the activities the
/// peer can participate in. To unregister a peer's application, call PeerCollabUnregisterApplication with this GUID.
///
/// Peer application registration information items are returned as individual PEER_APPLICATION_REGISTRATION_INFO structures.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumapplicationregistrationinfo
// NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerCollabEnumApplicationRegistrationInfo( PEER_APPLICATION_REGISTRATION_TYPE
// registrationType, HPEERENUM *phPeerEnum );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumApplicationRegistrationInfo")]
public static extern HRESULT PeerCollabEnumApplicationRegistrationInfo(PEER_APPLICATION_REGISTRATION_TYPE registrationType, out SafeHPEERENUM phPeerEnum);
/// The PeerCollabEnumApplicationRegistrationInfo function enumerates peer application information.
///
/// A PEER_APPLICATION_REGISTRATION_TYPE value that specifies whether the peer's application is registered to the current
/// user or all users of the peer's machine.
///
/// A list of structures.
///
///
/// An application is a set of software or software features available on the peer's endpoint. Commonly, this refers to software
/// packages that support peer networking activities, like games or other collaborative applications.
///
///
/// A peer's application has a GUID representing a single specific application. When an application is registered for a peer, this
/// GUID and the corresponding application can be made available to all trusted contacts of the peer, indicating the activities the
/// peer can participate in. To unregister a peer's application, call PeerCollabUnregisterApplication with this GUID.
///
/// Peer application registration information items are returned as individual PEER_APPLICATION_REGISTRATION_INFO structures.
///
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumApplicationRegistrationInfo")]
public static SafePeerList PeerCollabEnumApplicationRegistrationInfo(PEER_APPLICATION_REGISTRATION_TYPE registrationType) =>
PeerEnum(() => { PeerCollabEnumApplicationRegistrationInfo(registrationType, out var h).ThrowIfFailed(); return h; });
///
/// The PeerCollabEnumApplications function returns the handle to an enumeration that contains the applications registered to
/// a specific peer's endpoint(s).
///
///
/// Pointer to a PEER_ENDPOINT structure that contains the endpoint information for a peer whose applications will be enumerated.
/// If this parameter is set to NULL, the published application information for the local peer's endpoint is enumerated.
///
///
/// Pointer to the GUID value that uniquely identifies a particular application of the supplied peer. If this parameter is supplied,
/// the only peer application returned is the one that matches this GUID.
///
///
/// Pointer to the handle for the enumerated set of registered applications that correspond to the GUID returned in pObjectId. Pass
/// this handle to PeerGetNextItem to obtain each item in the enumerated set.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
///
///
/// In order to enumerate the applications for the specified endpoint successfully, application data must be available on the
/// endpoint. For application data to be available, one of the following must occur:
///
///
/// -
/// The endpoint must have been previously obtained by calling PeerCollabEnumEndpoints.
///
/// -
/// The local peer must have subscribed to the endpoint by calling PeerCollabSubscribeEndpointData.
///
/// -
/// The endpoint data must be refreshed by calling PeerCollabRefreshEndpointData successfully.
///
///
///
/// To obtain the individual peer applications, pass the returned handle to PeerGetNextItem. To close the enumeration and release
/// the resources associated with it, pass this handle to PeerEndEnumeration. Individual items returned by the enumeration must be
/// released with PeerFreeData.
///
/// Peer application data items are returned as individual PEER_APPLICATION structures.
///
/// The PeerCollabEnumApplications function returns an empty array for endpoints on the subnet that are not trusted contacts.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumapplications NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumApplications( PCPEER_ENDPOINT pcEndpoint, const GUID *pApplicationId, HPEERENUM *phPeerEnum );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumApplications")]
public static extern HRESULT PeerCollabEnumApplications(in PEER_ENDPOINT pcEndpoint, in Guid pApplicationId, out SafeHPEERENUM phPeerEnum);
///
/// The PeerCollabEnumApplications function returns the handle to an enumeration that contains the applications registered to
/// a specific peer's endpoint(s).
///
///
/// Pointer to a PEER_ENDPOINT structure that contains the endpoint information for a peer whose applications will be enumerated.
/// If this parameter is set to NULL, the published application information for the local peer's endpoint is enumerated.
///
///
/// Pointer to the GUID value that uniquely identifies a particular application of the supplied peer. If this parameter is supplied,
/// the only peer application returned is the one that matches this GUID.
///
///
/// Pointer to the handle for the enumerated set of registered applications that correspond to the GUID returned in pObjectId. Pass
/// this handle to PeerGetNextItem to obtain each item in the enumerated set.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
///
///
/// In order to enumerate the applications for the specified endpoint successfully, application data must be available on the
/// endpoint. For application data to be available, one of the following must occur:
///
///
/// -
/// The endpoint must have been previously obtained by calling PeerCollabEnumEndpoints.
///
/// -
/// The local peer must have subscribed to the endpoint by calling PeerCollabSubscribeEndpointData.
///
/// -
/// The endpoint data must be refreshed by calling PeerCollabRefreshEndpointData successfully.
///
///
///
/// To obtain the individual peer applications, pass the returned handle to PeerGetNextItem. To close the enumeration and release
/// the resources associated with it, pass this handle to PeerEndEnumeration. Individual items returned by the enumeration must be
/// released with PeerFreeData.
///
/// Peer application data items are returned as individual PEER_APPLICATION structures.
///
/// The PeerCollabEnumApplications function returns an empty array for endpoints on the subnet that are not trusted contacts.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumapplications NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumApplications( PCPEER_ENDPOINT pcEndpoint, const GUID *pApplicationId, HPEERENUM *phPeerEnum );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumApplications")]
public static extern HRESULT PeerCollabEnumApplications([In, Optional] IntPtr pcEndpoint, [In, Optional] IntPtr pApplicationId, out SafeHPEERENUM phPeerEnum);
///
/// The PeerCollabEnumApplications function returns the handle to an enumeration that contains the applications registered to
/// a specific peer's endpoint(s).
///
///
/// A PEER_ENDPOINT structure that contains the endpoint information for a peer whose applications will be enumerated.
/// If this parameter is set to NULL, the published application information for the local peer's endpoint is enumerated.
///
///
/// A GUID value that uniquely identifies a particular application of the supplied peer. If this parameter is supplied, the only
/// peer application returned is the one that matches this GUID.
///
///
/// A list of structures that contains the applications registered to a specific peer's endpoint(s).
///
///
///
/// In order to enumerate the applications for the specified endpoint successfully, application data must be available on the
/// endpoint. For application data to be available, one of the following must occur:
///
///
/// -
/// The endpoint must have been previously obtained by calling PeerCollabEnumEndpoints.
///
/// -
/// The local peer must have subscribed to the endpoint by calling PeerCollabSubscribeEndpointData.
///
/// -
/// The endpoint data must be refreshed by calling PeerCollabRefreshEndpointData successfully.
///
///
///
/// The PeerCollabEnumApplications function returns an empty array for endpoints on the subnet that are not trusted contacts.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumapplications NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumApplications( PCPEER_ENDPOINT pcEndpoint, const GUID *pApplicationId, HPEERENUM *phPeerEnum );
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumApplications")]
public static SafePeerList PeerCollabEnumApplications([In, Optional] PEER_ENDPOINT? pcEndpoint, [In, Optional] Guid? pApplicationId) =>
PeerEnum(() =>
{
SafeHPEERENUM h;
if (pcEndpoint.HasValue && pApplicationId.HasValue)
PeerCollabEnumApplications(pcEndpoint.Value, pApplicationId.Value, out h).ThrowIfFailed();
else
{
using var e = (SafeHGlobalStruct)pcEndpoint;
using var a = (SafeHGlobalStruct)pApplicationId;
PeerCollabEnumApplications(e, a, out h).ThrowIfFailed();
}
return h;
});
///
/// The PeerCollabEnumContacts function returns a handle to an enumerated set that contains all of the peer collaboration
/// network contacts currently available on the calling peer.
///
///
/// Handle to an enumerated set that contains all of the peer collaboration network contacts currently available on the calling
/// peer, excluding the "Me" contact.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
///
/// To obtain the individual peer contacts, pass the returned handle to PEER_CONTACT structures will be returned. To close the
/// enumeration and release the resources associated with it, pass this handle to PeerEndEnumeration. Individual items returned by
/// the enumeration must be released with PeerFreeData.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumcontacts NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumContacts( HPEERENUM *phPeerEnum );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumContacts")]
public static extern HRESULT PeerCollabEnumContacts(out SafeHPEERENUM phPeerEnum);
///
/// The PeerCollabEnumContacts function returns an enumerated set that contains all of the peer collaboration network
/// contacts currently available on the calling peer.
///
/// A list of of all currently available contacts.
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumcontacts NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumContacts( HPEERENUM *phPeerEnum );
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumContacts")]
public static SafePeerList PeerCollabEnumContacts() => PeerEnum(() => { PeerCollabEnumContacts(out var h).ThrowIfFailed(); return h; });
///
/// The PeerCollabEnumEndpoints function returns the handle to an enumeration that contains the endpoints associated with a
/// specific peer contact.
///
///
/// Pointer to a PEER_CONTACT structure that contains the contact information for a specific peer. This parameter must not be NULL.
///
///
/// Pointer to a handle for the enumerated set of endpoints that are associated with the supplied peer contact. Pass this handle to
/// PeerGetNextItem to obtain each item in the enumerated set.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// The operation requires the user to be signed in.
///
///
///
///
///
/// It is recommended that a contact record is updated using PeerCollabUpdateContact prior to calling
/// PeerCollabEnumEndpoints. Failure to do so can result in a return of E_INVALIDARG.
///
///
/// Endpoints will be available only for contacts with fWatch set to true. Only endpoints that have the "Me" contact of the
/// calling peer saved as a trusted contact and have WatcherPermissions set to allow will be available. A contact must also
/// be signed-in to the internet. In the event the contact is not signed-in, the error E_INVALIDARG will be returned.
///
///
/// To obtain the individual peer endpoints, pass the returned handle to PeerGetNextItem. An array of pointers to PEER_ENDPOINT
/// structures will be returned. If no endpoints are available, an empty array will be returned. To close the enumeration and
/// release the resources associated with it, pass this handle to PeerEndEnumeration. Individual items returned by the enumeration
/// must be released with PeerFreeData.
///
/// The limit for connections to a single contact is 50.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumendpoints NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumEndpoints( PCPEER_CONTACT pcContact, HPEERENUM *phPeerEnum );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumEndpoints")]
public static extern HRESULT PeerCollabEnumEndpoints(in PEER_CONTACT pcContact, out SafeHPEERENUM phPeerEnum);
///
/// The PeerCollabEnumEndpoints function returns an enumeration that contains the endpoints associated with a specific peer contact.
///
/// Pointer to a PEER_CONTACT structure that contains the contact information for a specific peer.
///
/// An enumeration of structures that contain the endpoints associated with a specific peer contact.
///
///
///
/// It is recommended that a contact record is updated using PeerCollabUpdateContact prior to calling
/// PeerCollabEnumEndpoints. Failure to do so can result in a return of E_INVALIDARG.
///
///
/// Endpoints will be available only for contacts with fWatch set to true. Only endpoints that have the "Me" contact of the
/// calling peer saved as a trusted contact and have WatcherPermissions set to allow will be available. A contact must also
/// be signed-in to the internet. In the event the contact is not signed-in, the error E_INVALIDARG will be returned.
///
/// The limit for connections to a single contact is 50.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumendpoints NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumEndpoints( PCPEER_CONTACT pcContact, HPEERENUM *phPeerEnum );
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumEndpoints")]
public static SafePeerList PeerCollabEnumEndpoints(in PEER_CONTACT pcContact) =>
PeerEnum(pcContact, i => { PeerCollabEnumEndpoints(i, out var h).ThrowIfFailed(); return h; });
///
/// The PeerCollabEnumObjects function returns the handle to an enumeration that contains the peer objects associated with a
/// specific peer's endpoint.
///
///
/// Pointer to a PEER_ENDPOINT structure that contains the endpoint information for a peer whose objects will be enumerated.
/// If this parameter is NULL the published objects of the local peer's contacts are returned.
///
///
/// Pointer to a GUID value that uniquely identifies a peer object with the supplied peer. If this parameter is supplied, the only
/// peer object returned is the one that matches this GUID.
///
///
/// Pointer to the handle for the enumerated set of peer objects that correspond to the GUID returned in pObjectId. Pass this handle
/// to PeerGetNextItem to obtain each item in the enumerated set.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// The operation requires the user to be signed in.
///
///
///
///
///
/// Peer objects are run-time data items associated with a particular application, such as a picture, an avatar, a certificate, or a
/// specific description. Each peer object must be smaller than 16K in size.
///
///
/// PeerCollabEnumObjects will return all of the objects published for the local peer. The objects can be published by more
/// than one application.
///
///
/// To obtain the individual peer objects, pass the returned handle to PeerGetNextItem. The peer objects are returned as an array of
/// pointers to the PEER_OBJECT structures. If the endpoint is not publishing any objects, an empty array will be returned. To close
/// the enumeration and release the resources associated with it, pass this handle to PeerEndEnumeration. Individual items returned
/// by the enumeration must be released with PeerFreeData.
///
/// To obtain a peer object successfully:
///
/// -
/// The endpoint must have been previously obtained by calling PeerCollabEnumEndpoints.
///
/// -
/// The local peer must have subscribed to the endpoint by calling PeerCollabSubscribeEndpointData.
///
/// -
/// The endpoint data must be refreshed by calling PeerCollabRefreshEndpointData successfully.
///
///
///
/// If the user is publishing a picture, the picture can be obtained by retrieving the corresponding object. The GUID for the
/// picture object is PEER_COLLAB_OBJECTID_USER_PICTURE.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumobjects NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumObjects( PCPEER_ENDPOINT pcEndpoint, const GUID *pObjectId, HPEERENUM *phPeerEnum );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumObjects")]
public static extern HRESULT PeerCollabEnumObjects(in PEER_ENDPOINT pcEndpoint, in Guid pObjectId, out SafeHPEERENUM phPeerEnum);
///
/// The PeerCollabEnumObjects function returns the handle to an enumeration that contains the peer objects associated with a
/// specific peer's endpoint.
///
///
/// Pointer to a PEER_ENDPOINT structure that contains the endpoint information for a peer whose objects will be enumerated.
/// If this parameter is NULL the published objects of the local peer's contacts are returned.
///
///
/// Pointer to a GUID value that uniquely identifies a peer object with the supplied peer. If this parameter is supplied, the only
/// peer object returned is the one that matches this GUID.
///
///
/// Pointer to the handle for the enumerated set of peer objects that correspond to the GUID returned in pObjectId. Pass this handle
/// to PeerGetNextItem to obtain each item in the enumerated set.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// The operation requires the user to be signed in.
///
///
///
///
///
/// Peer objects are run-time data items associated with a particular application, such as a picture, an avatar, a certificate, or a
/// specific description. Each peer object must be smaller than 16K in size.
///
///
/// PeerCollabEnumObjects will return all of the objects published for the local peer. The objects can be published by more
/// than one application.
///
///
/// To obtain the individual peer objects, pass the returned handle to PeerGetNextItem. The peer objects are returned as an array of
/// pointers to the PEER_OBJECT structures. If the endpoint is not publishing any objects, an empty array will be returned. To close
/// the enumeration and release the resources associated with it, pass this handle to PeerEndEnumeration. Individual items returned
/// by the enumeration must be released with PeerFreeData.
///
/// To obtain a peer object successfully:
///
/// -
/// The endpoint must have been previously obtained by calling PeerCollabEnumEndpoints.
///
/// -
/// The local peer must have subscribed to the endpoint by calling PeerCollabSubscribeEndpointData.
///
/// -
/// The endpoint data must be refreshed by calling PeerCollabRefreshEndpointData successfully.
///
///
///
/// If the user is publishing a picture, the picture can be obtained by retrieving the corresponding object. The GUID for the
/// picture object is PEER_COLLAB_OBJECTID_USER_PICTURE.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumobjects NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumObjects( PCPEER_ENDPOINT pcEndpoint, const GUID *pObjectId, HPEERENUM *phPeerEnum );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumObjects")]
public static extern HRESULT PeerCollabEnumObjects([In, Optional] IntPtr pcEndpoint, [In, Optional] IntPtr pObjectId, out SafeHPEERENUM phPeerEnum);
///
/// The PeerCollabEnumObjects function returns an enumeration that contains the peer objects associated with a specific
/// peer's endpoint.
///
///
/// A PEER_ENDPOINT structure that contains the endpoint information for a peer whose objects will be enumerated.
/// If this parameter is the published objects of the local peer's contacts are returned.
///
///
/// A GUID value that uniquely identifies a peer object with the supplied peer. If this parameter is supplied, the only peer object
/// returned is the one that matches this GUID.
///
/// The enumerated set of peer objects that correspond to the GUID returned in pObjectId.
///
///
/// Peer objects are run-time data items associated with a particular application, such as a picture, an avatar, a certificate, or a
/// specific description. Each peer object must be smaller than 16K in size.
///
///
/// PeerCollabEnumObjects will return all of the objects published for the local peer. The objects can be published by more
/// than one application.
///
/// To obtain a peer object successfully:
///
/// -
/// The endpoint must have been previously obtained by calling PeerCollabEnumEndpoints.
///
/// -
/// The local peer must have subscribed to the endpoint by calling PeerCollabSubscribeEndpointData.
///
/// -
/// The endpoint data must be refreshed by calling PeerCollabRefreshEndpointData successfully.
///
///
///
/// If the user is publishing a picture, the picture can be obtained by retrieving the corresponding object. The GUID for the
/// picture object is PEER_COLLAB_OBJECTID_USER_PICTURE.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumobjects NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumObjects( PCPEER_ENDPOINT pcEndpoint, const GUID *pObjectId, HPEERENUM *phPeerEnum );
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumObjects")]
public static SafePeerList PeerCollabEnumObjects([In, Optional] PEER_ENDPOINT? pcEndpoint, [In, Optional] Guid? pObjectId) => PeerEnum(() =>
{
SafeHPEERENUM h;
if (pcEndpoint.HasValue && pObjectId.HasValue)
PeerCollabEnumObjects(pcEndpoint.Value, pObjectId.Value, out h).ThrowIfFailed();
else
{
using var e = (SafeHGlobalStruct)pcEndpoint;
using var a = (SafeHGlobalStruct)pObjectId;
PeerCollabEnumObjects(e, a, out h).ThrowIfFailed();
}
return h;
});
///
/// The PeerCollabEnumPeopleNearMe function returns a handle to an enumerated set that contains all of the peer collaboration
/// network "people near me" endpoints currently available on the subnet of the calling peer.
///
///
/// Pointer to a handle of an enumerated set that contains all of the peer collaboration network "people near me" endpoints
/// currently available on the subnet of the calling peer.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// The operation requires the user to be signed in.
///
///
///
///
/// To obtain the individual peer "people near me" contacts, pass the returned handle to PeerGetNextItem. An array of pointers to
/// the PEER_PEOPLE_NEAR_ME structures are returned. To close the enumeration and release the resources associated with it, pass
/// this handle to PeerEndEnumeration. Individual items returned by the enumeration must be released with PeerFreeData.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumpeoplenearme NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumPeopleNearMe( HPEERENUM *phPeerEnum );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumPeopleNearMe")]
public static extern HRESULT PeerCollabEnumPeopleNearMe(out SafeHPEERENUM phPeerEnum);
///
/// The PeerCollabEnumPeopleNearMe function returns an enumerated set that contains all of the peer collaboration network
/// "people near me" endpoints currently available on the subnet of the calling peer.
///
///
/// An enumerated set that contains all of the peer collaboration network "people near me" endpoints currently available on the
/// subnet of the calling peer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabenumpeoplenearme NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabEnumPeopleNearMe( HPEERENUM *phPeerEnum );
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabEnumPeopleNearMe")]
public static SafePeerList PeerCollabEnumPeopleNearMe() => PeerEnum(() => { PeerCollabEnumPeopleNearMe(out var h).ThrowIfFailed(); return h; });
///
///
/// The PeerCollabExportContact function exports the contact data associated with a peer name to a string buffer. The buffer
/// contains contact data in XML format.
///
/// The PeerCollabAddContact function allows this XML string to be utilized by other peers.
///
///
/// Pointer to zero-terminated Unicode string that contains the name of the peer contact for which to export.
/// If this parameter is NULL, the "Me" contact information for the calling peer is exported.
///
///
///
/// Pointer to a zero-terminated string buffer that contains peer contact XML data where the peer names match the string supplied in pwzPeerName.
///
/// The memory returned here can be freed by calling PeerFreeData.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// One of the arguments is invalid.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabexportcontact NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabExportContact( PCWSTR pwzPeerName, PWSTR *ppwzContactData );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabExportContact")]
public static extern HRESULT PeerCollabExportContact([MarshalAs(UnmanagedType.LPWStr)] string pwzPeerName, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzContactData);
///
/// The PeerCollabGetAppLaunchInfo function obtains the peer application launch information, including the contact name, the
/// peer endpoint, and the invitation request.
///
///
/// Pointer to a PEER_APP_LAUNCH_INFO structure that receives the peer application launch data.
/// Free the memory associated with this structure by passing it to PeerFreeData.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_FOUND
/// The requested data does not exist.
///
///
///
///
/// When an application invite is accepted, the application is launched with the information sent as part of the application invite.
/// This information can be obtained by calling PeerCollabGetAppLaunchInfo.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabgetapplaunchinfo NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabGetAppLaunchInfo( PPEER_APP_LAUNCH_INFO *ppLaunchInfo );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetAppLaunchInfo")]
public static extern HRESULT PeerCollabGetAppLaunchInfo(out SafePeerData ppLaunchInfo);
//[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_APP_LAUNCH_INFO ppLaunchInfo);
/// The PeerCollabGetApplicationRegistrationInfo function obtains application-specific registration information.
/// Pointer to the GUID value that represents a particular peer's application registration flags.
///
/// A PEER_APPLICATION_REGISTRATION_TYPE enumeration value that describes whether the peer's application is registered to the
/// current user or all users of the local machine.
///
///
/// Pointer to the address of a PEER_APPLICATION_REGISTRATION_INFO structure that contains the information about a peer's specific
/// registered application. The data returned in this parameter can be freed by calling PeerFreeData.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_FOUND
/// The requested application is not registered for the given registrationType.
///
///
///
///
///
/// An application is a set of software or software features available on the peer's endpoint. Commonly, this refers to software
/// packages that support peer networking activities, like games or other collaborative applications.
///
///
/// A peer's application has a GUID representing a single application. When an application is registered for a peer, this GUID and
/// the corresponding application can be made available to all trusted contacts of the peer, indicating the activities the peer can
/// participate in. To unregister a peer's application, call PeerCollabUnregisterApplication with this GUID.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabgetapplicationregistrationinfo
// NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerCollabGetApplicationRegistrationInfo( const GUID *pApplicationId,
// PEER_APPLICATION_REGISTRATION_TYPE registrationType, PPEER_APPLICATION_REGISTRATION_INFO *ppApplication );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetApplicationRegistrationInfo")]
public static extern HRESULT PeerCollabGetApplicationRegistrationInfo(in Guid pApplicationId, PEER_APPLICATION_REGISTRATION_TYPE registrationType,
//[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_APPLICATION_REGISTRATION_INFO ppApplication);
out SafePeerData ppApplication);
/// The PeerCollabGetContact function obtains the information for a peer contact given the peer name of the contact.
///
/// Pointer to zero-terminated Unicode string that contains the name of the peer contact for which to obtain information.
/// If this parameter is NULL, the 'Me' contact information for the calling peer is returned.
///
///
///
/// Pointer to a pointer to a PEER_CONTACT structure. It receives the address of a PEER_CONTACT structure containing peer contact
/// information for the peer name supplied in pwzPeerName. When this parameter is NULL, this function returns E_INVALIDARG.
///
/// Call PeerFreeData on the address of the PEER_CONTACT structure to free this data.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabgetcontact NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabGetContact( PCWSTR pwzPeerName, PPEER_CONTACT *ppContact );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetContact")]
public static extern HRESULT PeerCollabGetContact([MarshalAs(UnmanagedType.LPWStr)] string pwzPeerName,
//[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_CONTACT ppContact);
out SafePeerData ppContact);
///
/// The PeerCollabGetEndpointName function retrieves the name of the current endpoint of the calling peer, as previously set
/// by a call to PeerCollabSetEndpointName.
///
///
/// Pointer to a zero-terminated Unicode string name of the peer endpoint currently used by the calling application.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// The operation requires the user to be signed in.
///
///
///
/// The endpoint name is limited to 25 Unicode characters. To free this data call PeerFreeData.
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabgetendpointname NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabGetEndpointName( PWSTR *ppwzEndpointName );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetEndpointName")]
public static extern HRESULT PeerCollabGetEndpointName([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzEndpointName);
///
/// The PeerCollabGetEventData function obtains the data associated with a peer collaboration event raised on the peer.
///
/// The peer collaboration network event handle obtained by a call to PeerCollabRegisterEvent.
///
/// Pointer to a list of PEER_COLLAB_EVENT_DATA structures that contain data about the peer collaboration network event. These data
/// structures must be freed after use by calling PeerFreeData.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_S_NO_EVENT_DATA
/// The event data is not present.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabgeteventdata NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabGetEventData( HPEEREVENT hPeerEvent, PPEER_COLLAB_EVENT_DATA *ppEventData );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetEventData")]
public static extern HRESULT PeerCollabGetEventData(HPEEREVENT hPeerEvent,
//[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_COLLAB_EVENT_DATA ppEventData);
out SafePeerData ppEventData);
///
/// The PeerCollabGetInvitationResponse function obtains the response from a peer previously invited to join a peer
/// collaboration activity.
///
/// Handle to an invitation to join a peer collaboration activity.
///
///
/// Pointer to the address of a PEER_INVITATION_RESPONSE structure that contains an invited peer's response to a previously
/// transmitted invitation request.
///
/// Free the memory associated with this structure by calling PeerFreeData.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_INVALIDARG
/// The provided handle is invalid.
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// PEER_E_NOT_FOUND
/// The invitation recipient could not be found.
///
/// -
/// PEER_E_INVITE_CANCELED
/// The invitation was previously canceled.
///
/// -
/// PEER_E_INVITE_RESPONSE_NOT_AVAILABLE
/// The response to the peer invitation is not available.
///
/// -
/// PEER_E_CONNECTION_FAILED
/// A connection to the graph or group has failed, or a direct connection in a graph or group has failed.
///
///
///
///
/// This function must be called after PeerCollabAsyncInviteContact or PeerCollabAsyncInviteEndpoint is called and the event handle
/// provided to PeerCollabRegisterEvent is signaled on the peer that sent the invitation.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabgetinvitationresponse NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabGetInvitationResponse( HANDLE hInvitation, PPEER_INVITATION_RESPONSE *ppInvitationResponse );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetInvitationResponse")]
public static extern HRESULT PeerCollabGetInvitationResponse(HANDLE hInvitation,
//[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_RESPONSE ppInvitationResponse);
out SafePeerData ppInvitationResponse);
///
/// The PeerCollabGetPresenceInfo function retrieves the presence information for the endpoint associated with a specific contact.
///
///
/// Pointer to a PEER_ENDPOINT structure that contains the specific endpoint associated with the contact specified in pcContact for
/// which presence information must be returned.
///
///
/// Pointer to the address of the PEER_PRESENCE_INFO structure that contains the requested presence data for the supplied endpoint.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The application did not make a previous call to PeerCollabStartup.
///
/// -
/// PEER_E_NOT_FOUND
/// The presence information for the specified endpoint was not found in the peer collaboration network.
///
///
///
///
/// To obtain a peer object successfully:
///
/// -
/// The endpoint must have been previously obtained by calling PeerCollabEnumEndpoints.
///
/// -
/// The local peer must have subscribed to the endpoint by calling PeerCollabSubscribeEndpointData.
///
/// -
/// The endpoint data must be refreshed by calling PeerCollabRefreshEndpointData successfully.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabgetpresenceinfo NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabGetPresenceInfo( PCPEER_ENDPOINT pcEndpoint, PPEER_PRESENCE_INFO *ppPresenceInfo );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetPresenceInfo")]
public static extern HRESULT PeerCollabGetPresenceInfo(in PEER_ENDPOINT pcEndpoint,
//[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_PRESENCE_INFO ppPresenceInfo);
out SafePeerData ppPresenceInfo);
///
/// The PeerCollabGetSigninOptions function obtains the peer's current signed-in peer collaboration network presence options.
///
/// The PEER_SIGNIN_FLAGS enumeration value is returned by this function.
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The application did not make a previous call to PeerCollabStartup.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// The application has not signed into the peer collaboration network with a previous call to PeerCollabSignIn.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabgetsigninoptions NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabGetSigninOptions( DWORD *pdwSigninOptions );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetSigninOptions")]
public static extern HRESULT PeerCollabGetSigninOptions(out PEER_SIGNIN_FLAGS pdwSigninOptions);
///
/// The PeerCollabInviteContact function sends an invitation to join a peer collaboration activity to a trusted contact. This
/// call is synchronous and, if successful, obtains a response from the contact.
///
/// Pointer to a PEER_CONTACT structure that contains the contact information associated with the invitee.
///
/// Pointer to a PEER_ENDPOINT structure that contains information about the invited peer. This peer is sent an invitation when this
/// API is called.
///
///
/// Pointer to a PEER_INVITATION structure that contains the invitation request to send to the endpoint(s) specified in pcEndpoint.
/// This parameter must not be set to NULL.
///
///
/// Pointer to a PEER_INVITATION_RESPONSE structure that receives an invited peer endpoint's responses to the invitation request.
/// If this call fails with an error, this parameter will be NULL.
/// Free the memory returned by calling PeerFreeData.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_TIMEOUT
/// The recipient of the invitation has not responded within 5 minutes.
///
///
///
///
///
/// This API ensures the peer that receives the invitation is the contact specified as input. The connection will fail if the
/// specific contact is not present on the endpoint specified. The use of PeerCollabInviteContact is recommended in place of
/// the less secure PeerCollabInviteEndpoint.
///
///
/// A toast will appear for the recipient of the invitation. This toast will be converted to a dialog box in which the user can
/// accept or decline the invitation. When the invitation is successfully accepted, the collaborative application is launched on the
/// recipient's machine.
///
///
/// To successfully receive the invitation, the application must be registered on the recipient's machine using
/// PeerCollabRegisterApplication. It is also possible for the sender of the invite to have failure codes returned because the
/// recipient has turned off application invites.
///
///
/// If the recipient is accepting invitations only from trusted contacts, then the sender of the invite must be added to the contact
/// store of the recipient machine. The sender must be added to the contact store before the invitation attempt. To add a contact to
/// the contact store, call PeerCollabAddContact.
///
/// The recipient of the invitation must respond within 5 minutes to avoid timeout.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabinvitecontact NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabInviteContact( PCPEER_CONTACT pcContact, PCPEER_ENDPOINT pcEndpoint, PCPEER_INVITATION pcInvitation,
// PPEER_INVITATION_RESPONSE *ppResponse );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabInviteContact")]
public static extern HRESULT PeerCollabInviteContact(in PEER_CONTACT pcContact, in PEER_ENDPOINT pcEndpoint, in PEER_INVITATION pcInvitation,
//[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_RESPONSE ppResponse);
out SafePeerData ppResponse);
///
/// The PeerCollabInviteEndpoint function sends an invitation to a specified peer endpoint to join the sender's peer
/// collaboration activity. This call is synchronous and, if successful, obtains a response from the peer endpoint.
///
///
///
/// Pointer to a PEER_ENDPOINT structure that contains information about the invited peer. This peer is sent an invitation when this
/// API is called.
///
/// This parameter must not be set to NULL.
///
///
/// Pointer to a PEER_INVITATION structure that contains the invitation request to send to the endpoint specified in pcEndpoint.
/// This parameter must not be set to NULL.
///
///
/// Pointer to a PEER_INVITATION_RESPONSE structure that receives an invited peer endpoint's responses to the invitation request.
/// If this call fails with an error, on output this parameter will be NULL.
/// Free the memory associated with this structure by pass it to PeerFreeData.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_TIMEOUT
/// The recipient of the invitation has not responded within 5 minutes.
///
///
///
///
///
/// This API sends an invitation to the endpoint specified as input. It does not guarantee that the recipient of the invite is the
/// specific contact that the user intended to send the invite to. To ensure that the invitation is sent to the correct contact,
/// call PeerCollabInviteContact.
///
///
/// A toast will appear for the recipient of the invitation. This toast will be converted to a dialog box in which the user can
/// accept or decline the invitation. When the invitation is successfully accepted, the collaborative application is launched on the
/// recipient's machine.
///
///
/// To successfully receive the invitation, the application must be registered on the recipient's machine using
/// PeerCollabRegisterApplication. It is also possible for the sender of the invite to have failure codes returned because the
/// recipient has turned off application invites.
///
/// The recipient of the invitation must respond within 5 minutes to avoid timeout.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabinviteendpoint NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabInviteEndpoint( PCPEER_ENDPOINT pcEndpoint, PCPEER_INVITATION pcInvitation, PPEER_INVITATION_RESPONSE *ppResponse );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabInviteEndpoint")]
public static extern HRESULT PeerCollabInviteEndpoint(in PEER_ENDPOINT pcEndpoint, in PEER_INVITATION pcInvitation,
//[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_RESPONSE ppResponse);
out SafePeerData ppResponse);
///
/// The PeerCollabParseContact function parses a Unicode string buffer containing contact XML data into a PEER_CONTACT data structure.
///
///
/// Pointer to zero-terminated Unicode string buffer that contains XML contact data as returned by functions like
/// PeerCollabQueryContactData or PeerCollabExportContact.
///
///
/// Pointer to the address of a PEER_CONTACT structure that contain the peer contact information parsed from pwzContactData. Free
/// the memory allocated by calling PeerFreeData.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabparsecontact NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabParseContact( PCWSTR pwzContactData, PPEER_CONTACT *ppContact );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabParseContact")]
public static extern HRESULT PeerCollabParseContact([MarshalAs(UnmanagedType.LPWStr)] string pwzContactData,
//[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_CONTACT ppContact);
out SafePeerData ppContact);
/// The PeerCollabQueryContactData function retrieves the contact information for the supplied peer endpoint.
///
/// Pointer to a PEER_ENDPOINT structure that contains the peer endpoint about which to obtain contact information.
/// If this parameter is set to NULL, the contact information for the current peer endpoint is obtained.
///
///
/// Pointer to a zero-terminated Unicode string buffer that contains the contact data for the endpoint supplied in pcEndpoint. Call
/// PeerFreeData to free the data.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_FOUND
/// The requested contact data does not exist. Try calling PeerCollabRefreshEndpointData before making another attempt.
///
///
///
///
/// To retrieve contact data for an endpoint successfully, one of the following must occur:
///
/// -
/// The endpoint must have been previously obtained by calling PeerCollabEnumEndpoints.
///
/// -
/// The local peer must have subscribed to the endpoint by calling PeerCollabSubscribeEndpointData.
///
/// -
/// The endpoint data must be refreshed by calling PeerCollabRefreshEndpointData successfully.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabquerycontactdata NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabQueryContactData( PCPEER_ENDPOINT pcEndpoint, PWSTR *ppwzContactData );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabQueryContactData")]
public static extern HRESULT PeerCollabQueryContactData(in PEER_ENDPOINT pcEndpoint,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzContactData);
/// The PeerCollabRefreshEndpointData function updates the calling peer node with new endpoint data.
///
/// Pointer to a PEER_ENDPOINT structure that contains the updated peer endpoint information for the current peer node.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
///
///
///
///
/// PeerCollabRefreshEndpointData allows an application to refresh data associated with the endpoint. Upon completion of the
/// API, the PEER_EVENT_REQUEST_STATUS_CHANGED event will be raised. The event will contain a success or failure code.
///
///
/// On success, the application can call functions like PeerCollabGetPresenceInfo, PeerCollabEnumApplications,
/// PeerCollabEnumObjects, and PeerCollabQueryContactData to obtain additional data. When the data is no longer needed it can be
/// deleted by calling PeerCollabDeleteEndpointData.
///
///
/// If a peer is subscribed to the endpoint, the subscribed data takes higher precedence than the data that was cached by calling
/// PeerCollabRefreshEndpointDataand will return PEER_EVENT_REQUEST_STATUS_CHANGED.
///
///
/// The PeerCollabRefreshEndpointData API takes a snapshot of the data for the specified endpoint. If endpoint data changes
/// after this snapshot is taken, the caller will have a stale copy of the data. If PeerCollabRefreshEndpointData is called by an
/// application multiple times for the same endpoint, the latest data received replaces the data stored from an earlier call to the
/// API. However, in order to ensure that the caller is notified of any changes and always has the latest copy,
/// PeerCollabSubscribeEndpointData is recommended instead of PeerCollabRefreshEndpointData.
///
/// The PeerCollabRefreshEndpointData function will timeout at 30 seconds.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabrefreshendpointdata NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabRefreshEndpointData( PCPEER_ENDPOINT pcEndpoint );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabRefreshEndpointData")]
public static extern HRESULT PeerCollabRefreshEndpointData(in PEER_ENDPOINT pcEndpoint);
///
/// The PeerCollabRegisterApplication function registers an application with the local computer so that it can be launched in
/// a peer collaboration activity.
///
///
/// Pointer to a PEER_APPLICATION_REGISTRATION_INFO structure that contains the UUID of the peer's application feature set as well
/// as any additional peer-specific data.
///
///
/// A PEER_APPLICATION_REGISTRATION_TYPE value that describes whether the peer's application is registered to the current
/// user or all users of the peer's machine.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
///
///
///
///
/// An application is a set of software or software features available on the peer's endpoint. Commonly, this refers to software
/// packages that support peer networking activities, like games or other collaborative applications.
///
///
/// The collaboration infrastructure can receive application invites from trusted contacts or from "People Near Me", which are based
/// on the scope the collaboration infrastructure is signed in with using PeerCollabSignin.
///
///
/// A peer's application has a GUID representing a single specific application. When an application is registered for a peer, this
/// GUID and the corresponding application can be made available to all trusted contacts of the peer, indicating the activities the
/// peer can participate in. To unregister a peer's application, call PeerCollabUnregisterApplication with this GUID.
///
///
/// When registering an application, it is recommended that developers specify a relative path, such as %ProgramFiles%,
/// instead of an absolute path. This prevents application failure due to a change in the location of application files. For
/// example, if the C:\ProgramFiles directory is moved to E:</b>.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabregisterapplication NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabRegisterApplication( PCPEER_APPLICATION_REGISTRATION_INFO pcApplication, PEER_APPLICATION_REGISTRATION_TYPE
// registrationType );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabRegisterApplication")]
public static extern HRESULT PeerCollabRegisterApplication(in PEER_APPLICATION_REGISTRATION_INFO pcApplication, PEER_APPLICATION_REGISTRATION_TYPE registrationType);
///
/// The PeerCollabRegisterEvent function registers an application with the peer collaboration infrastructure to receive
/// callbacks for specific peer collaboration events.
///
///
/// Handle created by CreateEvent that the application is signaled on when an event is triggered. When an application is signaled,
/// it must call PeerCollabGetEventData to retrieve events until PEER_S_NO_EVENT_DATA is returned.
///
/// The number of PEER_COLLAB_EVENT_REGISTRATION structures in pEventRegistrations.
///
/// An array of PEER_COLLAB_EVENT_REGISTRATION structures that specify the peer collaboration events for which the application
/// requests notification.
///
///
/// The peer event handle returned by this function. This handle is passed to PeerCollabGetEventData when a peer collaboration
/// network event is raised on the peer.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_SERVICE_NOT_AVAILABLE
/// An attempt was made to call PeerCollabRegisterEvent from an elevated process.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
///
/// If the p2phost.exe service is not running, this function will attempt to launch it for registrations that require p2phost.
///
/// If attempt is made to launch p2phost.exe from an elevated process, an error is returned. As a result, security cannot be
/// compromised by an application mistakenly granting administrative privileges to p2phost.exe. It is not possible to launch
/// p2phost.exe in a non-interactive mode, as it needs to display Windows dialog boxes for incoming invites.
///
///
/// When PeerCollabRegisterEvent is called on machines under heavy stress, the function may return the
/// PEER_E_SERVICE_NOT_AVAILABLE error code.
///
///
/// An application can call PeerCollabRegisterEvent multiple times, where each call is considered to be a separate
/// registration. When an event is registered multiple times, each registration receives a copy of the event.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabregisterevent NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabRegisterEvent( HANDLE hEvent, DWORD cEventRegistration, PEER_COLLAB_EVENT_REGISTRATION *pEventRegistrations, HPEEREVENT
// *phPeerEvent );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabRegisterEvent")]
public static extern HRESULT PeerCollabRegisterEvent(HANDLE hEvent, uint cEventRegistration, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] PEER_COLLAB_EVENT_REGISTRATION[] pEventRegistrations, out SafeCollabHPEEREVENT phPeerEvent);
/// The PeerCollabSetEndpointName function sets the name of the current endpoint used by the peer application.
///
/// Pointer to the new name of the current endpoint, represented as a zero-terminated Unicode string. An error is raised if the new
/// name is the same as the current one. An endpoint name is limited to 255 Unicode characters.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// The operation requires the user to be signed in.
///
///
///
///
/// An endpoint name is set to the machine name by default. However, a new endpoint name set by the PeerCollabSetEndpointName
/// function will persist across reboots.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabsetendpointname NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabSetEndpointName( PCWSTR pwzEndpointName );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabSetEndpointName")]
public static extern HRESULT PeerCollabSetEndpointName([MarshalAs(UnmanagedType.LPWStr)] string pwzEndpointName);
/// The PeerCollabSetObject function creates or updates a peer data object used in a peer collaboration network.
/// Pointer to a PEER_OBJECT structure that contains the peer object on the peer collaboration network.
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// The operation requires the user to be signed in.
///
///
///
///
///
/// Peer objects are run-time data items associated with a particular application, such as a picture, an avatar, a certificate, or a
/// specific description. Each peer object must be smaller than 16K in size and cannot be 0.
///
///
/// If an object is already published, PeerCollabSetObject will update the existing object data. The last application that
/// updates the object will take ownership of the object. As a result, if the application is terminated the object is deleted.
///
///
/// If an object's 'published' status is removed due to sign-out rather than the closure of the associated application, the
/// application is responsible for publishing the object the next time the user signs on.
///
///
/// Trusted contacts watching this peer object will have a PEER_EVENT_OBJECT_CHANGED event raised locally, signaling this
/// peer object's change in status.
///
/// PeerCollabSetObject can be used to publish at most 128 objects.
/// There is one object with a given GUID published at any given time.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabsetobject NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabSetObject( PCPEER_OBJECT pcObject );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabSetObject")]
public static extern HRESULT PeerCollabSetObject(in PEER_OBJECT pcObject);
///
/// The PeerCollabSetPresenceInfo function updates the caller's presence information to any contacts watching it.
///
///
/// Pointer to a PEER_PRESENCE_INFO structure that contains the new presence information to publish for the calling peer application.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
/// -
/// PEER_E_NOT_SIGNED_IN
/// The operation requires the user to be signed in.
///
///
///
///
///
/// Contacts watching this peer's presence will have a PEER_EVENT_PRESENCE_CHANGED event raised locally that signals this peer's
/// change in presence status. A peer's presence status cannot be set to offline while signed-in. By default, a peer's presence
/// status is 'online' and the descriptive text is NULL when signing in.
///
/// Any descriptive text for presence status is limited to 255 Unicode characters.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabsetpresenceinfo NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabSetPresenceInfo( PCPEER_PRESENCE_INFO pcPresenceInfo );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabSetPresenceInfo")]
public static extern HRESULT PeerCollabSetPresenceInfo(in PEER_PRESENCE_INFO pcPresenceInfo);
///
/// The PeerCollabShutdown function shuts down the Peer Collaboration infrastructure and releases any resources associated
/// with it.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The application did not make a previous call to PeerCollabStartup.
///
///
///
///
/// A call to this function decreases the number of references to the Peer Collaboration infrastructure by 1. If the reference count
/// equals 0, then all resources associated with the Peer Collaboration infrastructure are released.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabshutdown NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerCollabShutdown();
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabShutdown")]
public static extern HRESULT PeerCollabShutdown();
///
/// The PeerCollabSignin function signs the peer into a hosted Internet (serverless presence) or subnet ("People Near Me")
/// peer collaboration network presence provider.
///
/// Windows handle to the parent application signing in.
///
/// PEER_SIGNIN_FLAGS enumeration value that contains the presence provider sign-in options for the calling peer.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The application did not make a previous call to PeerCollabStartup.
///
/// -
/// PEER_E_SERVICE_NOT_AVAILABLE
/// An attempt was made to call PeerCollabSignIn from an elevated process.
///
/// -
/// PEER_S_NO_CONNECTIVITY
/// The sign-in succeeded, but IPv6 addresses are not available at this time.
///
///
///
///
/// If the p2phost.exe service is not running, this function will launch it.
///
/// If an attempt is made to launch the p2phost.exe service from an elevated process, an error is returned. As a result, security
/// cannot be compromised by an application mistakenly granting administrative privileges to p2phost.exe. It is not possible to
/// launch p2phost.exe in a non-interactive mode, as it needs to display Windows dialog boxes for incoming invites.
///
///
/// Calling PeerCollabSignin displays a sign-in user interface if the user has not authorized automatic sign-in. If
/// hwndParent is specified, the user interface window will use hwndParent as the parent window.
///
///
/// When a user signs in to "People Near Me", the user's display name, machine name, and IP address are published to peers on the
/// subnet. The user can optionally specify a display picture for publishing. This information is not published if
/// PeerCollabSignin is not called or the user signs out.
///
///
/// Once signed in, the user can view a list of peers signed in on the subnet and available for interaction. This list will be empty
/// if nobody else has signed in to "People Near Me" on the subnet.
///
///
/// Multiple applications can use the infrastructure at any given moment. It is not recommended for a single application to call
/// PeerCollabSignout, as other applications will not be able to use the infrastructure. Applications must also be prepared to
/// handle the user signing in and signing out, or situations where a machine goes to sleep or hibernation.
///
/// The PeerCollabSignin function currently requires up to two seconds to complete.
///
/// Display names are not necessarily unique. Users should verify the identity of the person using a display name by e-mail, phone,
/// or in person before accepting an invitation to interact.
///
///
/// To sign out of a peer collaborative network, call PeerCollabSignout with the same set of sign-in options. A user can also sign
/// out through the user interface.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabsignin NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabSignin( HWND hwndParent, DWORD dwSigninOptions );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabSignin")]
public static extern HRESULT PeerCollabSignin([Optional] HWND hwndParent, PEER_SIGNIN_FLAGS dwSigninOptions);
///
/// The PeerCollabSignout function signs a peer out of a specific type of peer collaboration network presence provider.
///
///
/// PEER_SIGNIN_FLAGS enumeration value that contains the presence provider sign-in options for the calling peer. This value is
/// obtained by calling PeerCollabGetSigninOptions from the peer application.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The application did not make a previous call to PeerCollabStartup.
///
///
///
///
///
/// If the local peer's collaboration infrastructure is signed out of both Internet and People Near Me presence, all transient
/// information like objects and the endpoint ID are deleted. Any application that uses this information must republish the
/// information. A single event that indicates signout is raised, instead of sending multiple individual events for each object or application.
///
///
/// Multiple applications can use the infrastructure at any given moment. It is not recommended for a single application to sign
/// out, as other applications will not be able to use the infrastructure. Applications must also be prepared to handle user sign in
/// and sign out, or situations where a machine goes to sleep or into hibernation.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabsignout NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabSignout( DWORD dwSigninOptions );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabSignout")]
public static extern HRESULT PeerCollabSignout(PEER_SIGNIN_FLAGS dwSigninOptions);
/// The PeerCollabStartup function initializes the Peer Collaboration infrastructure.
/// Contains the minimum version of the Peer Collaboration infrastructure requested by the peer.
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// PEER_E_UNSUPPORTED_VERSION
/// The requested version of the Peer Collaboration Infrastructure is not supported.
///
///
///
///
/// This function must be called before any other peer collaboration (PeerCollab*) functions are called.
///
/// When the application no longer requires the Peer Collaboration infrastructure, it must make a corresponding call to
/// PeerCollabShutdown. If PeerCollabStartup is called multiple times, there must be a separate corresponding call to
/// PeerCollabShutdown. All of the components of the infrastructure are cleaned up only when the last call to
/// PeerCollabShutdown occurs.
///
/// The current supported version is 1.0. Call
/// MAKEWORD(1, 0)
/// to generate this version number WORD value.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabstartup NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabStartup( WORD wVersionRequested );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabStartup")]
public static extern HRESULT PeerCollabStartup(ushort wVersionRequested = PEER_COLLAB_VERSION);
/// The PeerCollabSubscribeEndpointData function creates a subscription to an available endpoint.
/// Pointer to a PEER_ENDPOINT structure that contains the peer endpoint used to obtain presence information.
///
///
/// Returns S_OK or PEER_S_SUBSCRIPTION_EXISTS if the function succeeds. Otherwise, the function returns one of the following values.
///
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
///
///
/// PeerCollabSubscribeEndpointData is an asynchronous call, meaning that the process to subscribe the endpoint has been
/// started but not necessarily completed when this call returns. An application should wait for PEER_EVENT_REQUEST_STATUS_CHANGED
/// to get the result of the subscription request.
///
/// This function will timeout at 30 seconds.
///
/// PeerCollabSubscribeEndpointData can be called multiple times from different applications for the same endpoint. Each call
/// is reference counted; only when the last reference is released is a peer unsubscribed. To release the reference call PeerCollabUnsubscribeEndpointData.
///
///
/// When an application exits without calling PeerCollabUnsubscribeEndpointData, all of the references for that application are
/// released automatically.
///
///
/// To successfully call the PeerCollabGetPresenceInfo, PeerCollabEnumApplications, PeerCollabEnumObjects, and
/// PeerCollabQueryContactData APIs, an application must first call PeerCollabSubscribeEndpointData.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabsubscribeendpointdata NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabSubscribeEndpointData( const PCPEER_ENDPOINT pcEndpoint );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabSubscribeEndpointData")]
public static extern HRESULT PeerCollabSubscribeEndpointData(in PEER_ENDPOINT pcEndpoint);
///
/// The PeerCollabUnregisterApplication function unregisters the specific applications of a peer from the local computer.
///
/// Pointer to the GUID value that represents a particular peer's application.
///
/// A PEER_APPLICATION_REGISTRATION_TYPE value that describes whether the peer's application is deregistered for the current user or
/// all users of the peer's machine.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_FOUND
/// The application requested to unregister was not registered for the given registrationType.
///
///
///
///
///
/// An application is a set of software or software features available on the peer's endpoint. Commonly, this refers to software
/// packages that support peer networking activities, like games or other collaborative applications.
///
///
/// The collaboration infrastructure can receive application invites from trusted contacts or from "People Near Me", which are based
/// on what scope the collaboration infrastructure is signed in with using PeerCollabSignin.
///
///
/// A peer's application has a GUID representing a single specific application. When application is registered for a peer, this GUID
/// and the corresponding application can be made available to all trusted contacts of the peer, indicating the activities the peer
/// can participate in. To unregister a peer's application, call PeerCollabUnregisterApplication with this GUID.
///
/// To unregister the application for all users, the caller of this API must be elevated.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabunregisterapplication NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabUnregisterApplication( const GUID *pApplicationId, PEER_APPLICATION_REGISTRATION_TYPE registrationType );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabUnregisterApplication")]
public static extern HRESULT PeerCollabUnregisterApplication(in Guid pApplicationId, PEER_APPLICATION_REGISTRATION_TYPE registrationType);
///
/// The PeerCollabUnregisterEvent function deregisters an application from notification about specific peer collaboration events.
///
///
/// Handle to the peer collaboration event the peer application will deregister. This handle is obtained with a previous call to PeerCollabRegisterEvent.
///
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabunregisterevent NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabUnregisterEvent( HPEEREVENT hPeerEvent );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabUnregisterEvent")]
public static extern HRESULT PeerCollabUnregisterEvent(IntPtr hPeerEvent);
/// The PeerCollabUnsubscribeEndpointData function removes a subscription to an endpoint created with PeerCollabSubscribeEndpointData.
/// Pointer to a PEER_ENDPOINT structure that contains the peer endpoint that is used to remove the subscription.
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
/// -
/// PEER_E_NOT_INITIALIZED
/// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
///
///
///
///
/// Each call is reference counted. As a result, the peer is unsubscribed only when the last reference is released.
/// The PeerCollabUnsubscribeEndpointData function will timeout at 30 seconds.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabunsubscribeendpointdata NOT_BUILD_WINDOWS_DEPRECATE
// HRESULT PeerCollabUnsubscribeEndpointData( const PCPEER_ENDPOINT pcEndpoint );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabUnsubscribeEndpointData")]
public static extern HRESULT PeerCollabUnsubscribeEndpointData(in PEER_ENDPOINT pcEndpoint);
///
/// The PeerCollabUpdateContact function updates the information associated with a peer contact specified in the local
/// contact store of the caller.
///
/// Pointer to a PEER_CONTACT structure that contains the updated information for a specific peer contact.
///
/// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// E_OUTOFMEMORY
/// There is not enough memory to support this operation.
///
/// -
/// E_INVALIDARG
/// One of the arguments is invalid.
///
///
///
///
///
/// If the contact provided is the 'Me' contact, only the nickname, display name and email address can be changed. If a nickname is
/// changed for a contact signed in to "People Near Me", the structure PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA with changeType of
/// PEER_CHANGE_UPDATED will be raised.
///
/// The PeerCollabUpdateContact function will timeout at 30 seconds.
///
// https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercollabupdatecontact NOT_BUILD_WINDOWS_DEPRECATE HRESULT
// PeerCollabUpdateContact( PCPEER_CONTACT pContact );
[DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
[PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabUpdateContact")]
public static extern HRESULT PeerCollabUpdateContact(in PEER_CONTACT pContact);
/// Provides a handle to a peer collaboration network event.
[StructLayout(LayoutKind.Sequential)]
public struct HPEEREVENT : IHandle
{
private IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HPEEREVENT(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HPEEREVENT NULL => new HPEEREVENT(IntPtr.Zero);
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HPEEREVENT h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HPEEREVENT(IntPtr h) => new HPEEREVENT(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HPEEREVENT h1, HPEEREVENT h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HPEEREVENT h1, HPEEREVENT h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HPEEREVENT h && handle == h.handle;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
/// Provides a for that is disposed using .
public class SafeCollabHPEEREVENT : SafeHANDLE
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeCollabHPEEREVENT(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeCollabHPEEREVENT() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HPEEREVENT(SafeCollabHPEEREVENT h) => h.handle;
///
protected override bool InternalReleaseHandle() => PeerCollabUnregisterEvent(handle).Succeeded;
}
/// Provides a for P2P collaboration handle that is disposed using .
public class SafePeerCollabHandle : SafeHANDLE
{
/// Initializes a new instance of the class.
private SafePeerCollabHandle() : base() { }
///
protected override bool InternalReleaseHandle() => PeerCollabCloseHandle(handle).Succeeded;
}
}
}