diff --git a/PInvoke/P2P/CorrelationReport.md b/PInvoke/P2P/CorrelationReport.md
new file mode 100644
index 00000000..05e2ccbe
--- /dev/null
+++ b/PInvoke/P2P/CorrelationReport.md
@@ -0,0 +1,173 @@
+## Correlation report for p2p.dll
+PInvoke API (methods, structures and constants) imported from Windows P2P.dll.
+
+### Methods (87% complete, 101 of 115 functions)
+Native Method | Header | Managed Method
+--- | --- | ---
+[DllMain](https://www.google.com/search?num=5&q=DllMain+site%3Adocs.microsoft.com) | |
+[PeerCollabAddContact](https://www.google.com/search?num=5&q=PeerCollabAddContact+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabAddContact](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabAddContact)
+[PeerCollabAsyncInviteContact](https://www.google.com/search?num=5&q=PeerCollabAsyncInviteContact+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabAsyncInviteContact](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabAsyncInviteContact)
+[PeerCollabAsyncInviteEndpoint](https://www.google.com/search?num=5&q=PeerCollabAsyncInviteEndpoint+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabAsyncInviteEndpoint](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabAsyncInviteEndpoint)
+[PeerCollabCancelInvitation](https://www.google.com/search?num=5&q=PeerCollabCancelInvitation+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabCancelInvitation](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabCancelInvitation)
+[PeerCollabCloseHandle](https://www.google.com/search?num=5&q=PeerCollabCloseHandle+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabCloseHandle](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabCloseHandle)
+[PeerCollabDeleteContact](https://www.google.com/search?num=5&q=PeerCollabDeleteContact+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabDeleteContact](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabDeleteContact)
+[PeerCollabDeleteEndpointData](https://www.google.com/search?num=5&q=PeerCollabDeleteEndpointData+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabDeleteEndpointData](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabDeleteEndpointData)
+[PeerCollabDeleteObject](https://www.google.com/search?num=5&q=PeerCollabDeleteObject+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabDeleteObject](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabDeleteObject)
+[PeerCollabEnumApplicationRegistrationInfo](https://www.google.com/search?num=5&q=PeerCollabEnumApplicationRegistrationInfo+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabEnumApplicationRegistrationInfo](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabEnumApplicationRegistrationInfo)
+[PeerCollabEnumApplications](https://www.google.com/search?num=5&q=PeerCollabEnumApplications+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabEnumApplications](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabEnumApplications)
+[PeerCollabEnumContacts](https://www.google.com/search?num=5&q=PeerCollabEnumContacts+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabEnumContacts](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabEnumContacts)
+[PeerCollabEnumEndpoints](https://www.google.com/search?num=5&q=PeerCollabEnumEndpoints+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabEnumEndpoints](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabEnumEndpoints)
+[PeerCollabEnumObjects](https://www.google.com/search?num=5&q=PeerCollabEnumObjects+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabEnumObjects](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabEnumObjects)
+[PeerCollabEnumPeopleNearMe](https://www.google.com/search?num=5&q=PeerCollabEnumPeopleNearMe+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabEnumPeopleNearMe](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabEnumPeopleNearMe)
+[PeerCollabExportContact](https://www.google.com/search?num=5&q=PeerCollabExportContact+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabExportContact](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabExportContact)
+[PeerCollabGetAppLaunchInfo](https://www.google.com/search?num=5&q=PeerCollabGetAppLaunchInfo+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabGetAppLaunchInfo](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabGetAppLaunchInfo)
+[PeerCollabGetApplicationRegistrationInfo](https://www.google.com/search?num=5&q=PeerCollabGetApplicationRegistrationInfo+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabGetApplicationRegistrationInfo](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabGetApplicationRegistrationInfo)
+[PeerCollabGetContact](https://www.google.com/search?num=5&q=PeerCollabGetContact+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabGetContact](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabGetContact)
+[PeerCollabGetEndpointName](https://www.google.com/search?num=5&q=PeerCollabGetEndpointName+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabGetEndpointName](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabGetEndpointName)
+[PeerCollabGetEventData](https://www.google.com/search?num=5&q=PeerCollabGetEventData+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabGetEventData](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabGetEventData)
+[PeerCollabGetInvitationResponse](https://www.google.com/search?num=5&q=PeerCollabGetInvitationResponse+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabGetInvitationResponse](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabGetInvitationResponse)
+[PeerCollabGetPresenceInfo](https://www.google.com/search?num=5&q=PeerCollabGetPresenceInfo+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabGetPresenceInfo](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabGetPresenceInfo)
+[PeerCollabGetSigninOptions](https://www.google.com/search?num=5&q=PeerCollabGetSigninOptions+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabGetSigninOptions](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabGetSigninOptions)
+[PeerCollabInviteContact](https://www.google.com/search?num=5&q=PeerCollabInviteContact+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabInviteContact](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabInviteContact)
+[PeerCollabInviteEndpoint](https://www.google.com/search?num=5&q=PeerCollabInviteEndpoint+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabInviteEndpoint](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabInviteEndpoint)
+[PeerCollabParseContact](https://www.google.com/search?num=5&q=PeerCollabParseContact+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabParseContact](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabParseContact)
+[PeerCollabQueryContactData](https://www.google.com/search?num=5&q=PeerCollabQueryContactData+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabQueryContactData](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabQueryContactData)
+[PeerCollabRefreshEndpointData](https://www.google.com/search?num=5&q=PeerCollabRefreshEndpointData+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabRefreshEndpointData](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabRefreshEndpointData)
+[PeerCollabRegisterApplication](https://www.google.com/search?num=5&q=PeerCollabRegisterApplication+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabRegisterApplication](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabRegisterApplication)
+[PeerCollabRegisterEvent](https://www.google.com/search?num=5&q=PeerCollabRegisterEvent+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabRegisterEvent](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabRegisterEvent)
+[PeerCollabSetEndpointName](https://www.google.com/search?num=5&q=PeerCollabSetEndpointName+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabSetEndpointName](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabSetEndpointName)
+[PeerCollabSetObject](https://www.google.com/search?num=5&q=PeerCollabSetObject+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabSetObject](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabSetObject)
+[PeerCollabSetPresenceInfo](https://www.google.com/search?num=5&q=PeerCollabSetPresenceInfo+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabSetPresenceInfo](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabSetPresenceInfo)
+[PeerCollabShutdown](https://www.google.com/search?num=5&q=PeerCollabShutdown+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabShutdown](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabShutdown)
+[PeerCollabSignin](https://www.google.com/search?num=5&q=PeerCollabSignin+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabSignin](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabSignin)
+[PeerCollabSignout](https://www.google.com/search?num=5&q=PeerCollabSignout+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabSignout](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabSignout)
+[PeerCollabStartup](https://www.google.com/search?num=5&q=PeerCollabStartup+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabStartup](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabStartup)
+[PeerCollabSubscribeEndpointData](https://www.google.com/search?num=5&q=PeerCollabSubscribeEndpointData+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabSubscribeEndpointData](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabSubscribeEndpointData)
+[PeerCollabUnregisterApplication](https://www.google.com/search?num=5&q=PeerCollabUnregisterApplication+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabUnregisterApplication](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabUnregisterApplication)
+[PeerCollabUnregisterEvent](https://www.google.com/search?num=5&q=PeerCollabUnregisterEvent+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabUnregisterEvent](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabUnregisterEvent)
+[PeerCollabUnsubscribeEndpointData](https://www.google.com/search?num=5&q=PeerCollabUnsubscribeEndpointData+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabUnsubscribeEndpointData](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabUnsubscribeEndpointData)
+[PeerCollabUpdateContact](https://www.google.com/search?num=5&q=PeerCollabUpdateContact+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCollabUpdateContact](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCollabUpdateContact)
+[PeerCreatePeerName](https://www.google.com/search?num=5&q=PeerCreatePeerName+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerCreatePeerName](https://github.com/dahall/Vanara/search?l=C%23&q=PeerCreatePeerName)
+[PeerEndEnumeration](https://www.google.com/search?num=5&q=PeerEndEnumeration+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerEndEnumeration](https://github.com/dahall/Vanara/search?l=C%23&q=PeerEndEnumeration)
+[PeerEnumGroups](https://www.google.com/search?num=5&q=PeerEnumGroups+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerEnumGroups](https://github.com/dahall/Vanara/search?l=C%23&q=PeerEnumGroups)
+[PeerEnumIdentities](https://www.google.com/search?num=5&q=PeerEnumIdentities+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerEnumIdentities](https://github.com/dahall/Vanara/search?l=C%23&q=PeerEnumIdentities)
+[PeerFreeData](https://www.google.com/search?num=5&q=PeerFreeData+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerFreeData](https://github.com/dahall/Vanara/search?l=C%23&q=PeerFreeData)
+[PeerGetItemCount](https://www.google.com/search?num=5&q=PeerGetItemCount+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGetItemCount](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGetItemCount)
+[PeerGetNextItem](https://www.google.com/search?num=5&q=PeerGetNextItem+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGetNextItem](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGetNextItem)
+[PeerGraphShutdown](https://www.google.com/search?num=5&q=PeerGraphShutdown+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGraphShutdown](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGraphShutdown)
+[PeerGraphStartup](https://www.google.com/search?num=5&q=PeerGraphStartup+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGraphStartup](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGraphStartup)
+[PeerGroupAddRecord](https://www.google.com/search?num=5&q=PeerGroupAddRecord+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupAddRecord](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupAddRecord)
+[PeerGroupClose](https://www.google.com/search?num=5&q=PeerGroupClose+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupClose](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupClose)
+[PeerGroupCloseDirectConnection](https://www.google.com/search?num=5&q=PeerGroupCloseDirectConnection+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupCloseDirectConnection](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupCloseDirectConnection)
+[PeerGroupConnect](https://www.google.com/search?num=5&q=PeerGroupConnect+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupConnect](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupConnect)
+[PeerGroupConnectByAddress](https://www.google.com/search?num=5&q=PeerGroupConnectByAddress+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupConnectByAddress](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupConnectByAddress)
+[PeerGroupCreate](https://www.google.com/search?num=5&q=PeerGroupCreate+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupCreate](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupCreate)
+[PeerGroupCreateInvitation](https://www.google.com/search?num=5&q=PeerGroupCreateInvitation+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupCreateInvitation](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupCreateInvitation)
+[PeerGroupCreatePasswordInvitation](https://www.google.com/search?num=5&q=PeerGroupCreatePasswordInvitation+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupCreatePasswordInvitation](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupCreatePasswordInvitation)
+[PeerGroupDelete](https://www.google.com/search?num=5&q=PeerGroupDelete+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupDelete](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupDelete)
+[PeerGroupDeleteRecord](https://www.google.com/search?num=5&q=PeerGroupDeleteRecord+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupDeleteRecord](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupDeleteRecord)
+[PeerGroupEnumConnections](https://www.google.com/search?num=5&q=PeerGroupEnumConnections+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupEnumConnections](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupEnumConnections)
+[PeerGroupEnumMembers](https://www.google.com/search?num=5&q=PeerGroupEnumMembers+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupEnumMembers](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupEnumMembers)
+[PeerGroupEnumRecords](https://www.google.com/search?num=5&q=PeerGroupEnumRecords+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupEnumRecords](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupEnumRecords)
+[PeerGroupExportConfig](https://www.google.com/search?num=5&q=PeerGroupExportConfig+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupExportConfig](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupExportConfig)
+[PeerGroupExportDatabase](https://www.google.com/search?num=5&q=PeerGroupExportDatabase+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupExportDatabase](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupExportDatabase)
+[PeerGroupGetEventData](https://www.google.com/search?num=5&q=PeerGroupGetEventData+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupGetEventData](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupGetEventData)
+[PeerGroupGetProperties](https://www.google.com/search?num=5&q=PeerGroupGetProperties+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupGetProperties](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupGetProperties)
+[PeerGroupGetRecord](https://www.google.com/search?num=5&q=PeerGroupGetRecord+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupGetRecord](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupGetRecord)
+[PeerGroupGetStatus](https://www.google.com/search?num=5&q=PeerGroupGetStatus+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupGetStatus](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupGetStatus)
+[PeerGroupHandlePowerEvent](https://www.google.com/search?num=5&q=PeerGroupHandlePowerEvent+site%3Adocs.microsoft.com) | |
+[PeerGroupImportConfig](https://www.google.com/search?num=5&q=PeerGroupImportConfig+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupImportConfig](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupImportConfig)
+[PeerGroupImportDatabase](https://www.google.com/search?num=5&q=PeerGroupImportDatabase+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupImportDatabase](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupImportDatabase)
+[PeerGroupIssueCredentials](https://www.google.com/search?num=5&q=PeerGroupIssueCredentials+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupIssueCredentials](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupIssueCredentials)
+[PeerGroupJoin](https://www.google.com/search?num=5&q=PeerGroupJoin+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupJoin](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupJoin)
+[PeerGroupOpen](https://www.google.com/search?num=5&q=PeerGroupOpen+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupOpen](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupOpen)
+[PeerGroupOpenDirectConnection](https://www.google.com/search?num=5&q=PeerGroupOpenDirectConnection+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupOpenDirectConnection](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupOpenDirectConnection)
+[PeerGroupParseInvitation](https://www.google.com/search?num=5&q=PeerGroupParseInvitation+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupParseInvitation](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupParseInvitation)
+[PeerGroupPasswordJoin](https://www.google.com/search?num=5&q=PeerGroupPasswordJoin+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupPasswordJoin](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupPasswordJoin)
+[PeerGroupPeerTimeToUniversalTime](https://www.google.com/search?num=5&q=PeerGroupPeerTimeToUniversalTime+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupPeerTimeToUniversalTime](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupPeerTimeToUniversalTime)
+[PeerGroupRegisterEvent](https://www.google.com/search?num=5&q=PeerGroupRegisterEvent+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupRegisterEvent](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupRegisterEvent)
+[PeerGroupResumePasswordAuthentication](https://www.google.com/search?num=5&q=PeerGroupResumePasswordAuthentication+site%3Adocs.microsoft.com) | |
+[PeerGroupSearchRecords](https://www.google.com/search?num=5&q=PeerGroupSearchRecords+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupSearchRecords](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupSearchRecords)
+[PeerGroupSendData](https://www.google.com/search?num=5&q=PeerGroupSendData+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupSendData](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupSendData)
+[PeerGroupSetProperties](https://www.google.com/search?num=5&q=PeerGroupSetProperties+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupSetProperties](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupSetProperties)
+[PeerGroupShutdown](https://www.google.com/search?num=5&q=PeerGroupShutdown+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupShutdown](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupShutdown)
+[PeerGroupStartup](https://www.google.com/search?num=5&q=PeerGroupStartup+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupStartup](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupStartup)
+[PeerGroupUniversalTimeToPeerTime](https://www.google.com/search?num=5&q=PeerGroupUniversalTimeToPeerTime+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupUniversalTimeToPeerTime](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupUniversalTimeToPeerTime)
+[PeerGroupUnregisterEvent](https://www.google.com/search?num=5&q=PeerGroupUnregisterEvent+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupUnregisterEvent](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupUnregisterEvent)
+[PeerGroupUpdateRecord](https://www.google.com/search?num=5&q=PeerGroupUpdateRecord+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerGroupUpdateRecord](https://github.com/dahall/Vanara/search?l=C%23&q=PeerGroupUpdateRecord)
+[PeerHostNameToPeerName](https://www.google.com/search?num=5&q=PeerHostNameToPeerName+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerHostNameToPeerName](https://github.com/dahall/Vanara/search?l=C%23&q=PeerHostNameToPeerName)
+[PeerIdentityCreate](https://www.google.com/search?num=5&q=PeerIdentityCreate+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerIdentityCreate](https://github.com/dahall/Vanara/search?l=C%23&q=PeerIdentityCreate)
+[PeerIdentityDelete](https://www.google.com/search?num=5&q=PeerIdentityDelete+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerIdentityDelete](https://github.com/dahall/Vanara/search?l=C%23&q=PeerIdentityDelete)
+[PeerIdentityExport](https://www.google.com/search?num=5&q=PeerIdentityExport+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerIdentityExport](https://github.com/dahall/Vanara/search?l=C%23&q=PeerIdentityExport)
+[PeerIdentityGetCert](https://www.google.com/search?num=5&q=PeerIdentityGetCert+site%3Adocs.microsoft.com) | |
+[PeerIdentityGetCryptKey](https://www.google.com/search?num=5&q=PeerIdentityGetCryptKey+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerIdentityGetCryptKey](https://github.com/dahall/Vanara/search?l=C%23&q=PeerIdentityGetCryptKey)
+[PeerIdentityGetDefault](https://www.google.com/search?num=5&q=PeerIdentityGetDefault+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerIdentityGetDefault](https://github.com/dahall/Vanara/search?l=C%23&q=PeerIdentityGetDefault)
+[PeerIdentityGetFriendlyName](https://www.google.com/search?num=5&q=PeerIdentityGetFriendlyName+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerIdentityGetFriendlyName](https://github.com/dahall/Vanara/search?l=C%23&q=PeerIdentityGetFriendlyName)
+[PeerIdentityGetXML](https://www.google.com/search?num=5&q=PeerIdentityGetXML+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerIdentityGetXML](https://github.com/dahall/Vanara/search?l=C%23&q=PeerIdentityGetXML)
+[PeerIdentityImport](https://www.google.com/search?num=5&q=PeerIdentityImport+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerIdentityImport](https://github.com/dahall/Vanara/search?l=C%23&q=PeerIdentityImport)
+[PeerIdentitySetFriendlyName](https://www.google.com/search?num=5&q=PeerIdentitySetFriendlyName+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerIdentitySetFriendlyName](https://github.com/dahall/Vanara/search?l=C%23&q=PeerIdentitySetFriendlyName)
+[PeerNameToPeerHostName](https://www.google.com/search?num=5&q=PeerNameToPeerHostName+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerNameToPeerHostName](https://github.com/dahall/Vanara/search?l=C%23&q=PeerNameToPeerHostName)
+[PeerPnrpEndResolve](https://www.google.com/search?num=5&q=PeerPnrpEndResolve+site%3Adocs.microsoft.com) | |
+[PeerPnrpGetCloudInfo](https://www.google.com/search?num=5&q=PeerPnrpGetCloudInfo+site%3Adocs.microsoft.com) | |
+[PeerPnrpGetEndpoint](https://www.google.com/search?num=5&q=PeerPnrpGetEndpoint+site%3Adocs.microsoft.com) | |
+[PeerPnrpRegister](https://www.google.com/search?num=5&q=PeerPnrpRegister+site%3Adocs.microsoft.com) | |
+[PeerPnrpResolve](https://www.google.com/search?num=5&q=PeerPnrpResolve+site%3Adocs.microsoft.com) | |
+[PeerPnrpShutdown](https://www.google.com/search?num=5&q=PeerPnrpShutdown+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerPnrpShutdown](https://github.com/dahall/Vanara/search?l=C%23&q=PeerPnrpShutdown)
+[PeerPnrpStartResolve](https://www.google.com/search?num=5&q=PeerPnrpStartResolve+site%3Adocs.microsoft.com) | |
+[PeerPnrpStartup](https://www.google.com/search?num=5&q=PeerPnrpStartup+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PeerPnrpStartup](https://github.com/dahall/Vanara/search?l=C%23&q=PeerPnrpStartup)
+[PeerPnrpUnregister](https://www.google.com/search?num=5&q=PeerPnrpUnregister+site%3Adocs.microsoft.com) | |
+[PeerPnrpUpdateRegistration](https://www.google.com/search?num=5&q=PeerPnrpUpdateRegistration+site%3Adocs.microsoft.com) | |
+[PeerSSPAddCredentials](https://www.google.com/search?num=5&q=PeerSSPAddCredentials+site%3Adocs.microsoft.com) | |
+[PeerSSPRemoveCredentials](https://www.google.com/search?num=5&q=PeerSSPRemoveCredentials+site%3Adocs.microsoft.com) | |
+### Structures
+Native Structure | Header | Managed Structure
+--- | --- | ---
+[HGRAPH](https://www.google.com/search?num=5&q=HGRAPH+site%3Adocs.microsoft.com) | | [Vanara.PInvoke.P2P.HGRAPH](https://github.com/dahall/Vanara/search?l=C%23&q=HGRAPH)
+[HGROUP](https://www.google.com/search?num=5&q=HGROUP+site%3Adocs.microsoft.com) | | [Vanara.PInvoke.P2P.HGROUP](https://github.com/dahall/Vanara/search?l=C%23&q=HGROUP)
+[HPEERENUM](https://www.google.com/search?num=5&q=HPEERENUM+site%3Adocs.microsoft.com) | | [Vanara.PInvoke.P2P.HPEERENUM](https://github.com/dahall/Vanara/search?l=C%23&q=HPEERENUM)
+[HPEEREVENT](https://www.google.com/search?num=5&q=HPEEREVENT+site%3Adocs.microsoft.com) | | [Vanara.PInvoke.P2P.HPEEREVENT](https://github.com/dahall/Vanara/search?l=C%23&q=HPEEREVENT)
+[PEER_ADDRESS](https://www.google.com/search?num=5&q=PEER_ADDRESS+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_ADDRESS](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_ADDRESS)
+[PEER_APP_LAUNCH_INFO](https://www.google.com/search?num=5&q=PEER_APP_LAUNCH_INFO+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_APP_LAUNCH_INFO](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_APP_LAUNCH_INFO)
+[PEER_APPLICATION](https://www.google.com/search?num=5&q=PEER_APPLICATION+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_APPLICATION](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_APPLICATION)
+[PEER_APPLICATION_REGISTRATION_INFO](https://www.google.com/search?num=5&q=PEER_APPLICATION_REGISTRATION_INFO+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_APPLICATION_REGISTRATION_INFO](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_APPLICATION_REGISTRATION_INFO)
+[PEER_COLLAB_EVENT_DATA](https://www.google.com/search?num=5&q=PEER_COLLAB_EVENT_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_COLLAB_EVENT_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_COLLAB_EVENT_DATA)
+[PEER_COLLAB_EVENT_REGISTRATION](https://www.google.com/search?num=5&q=PEER_COLLAB_EVENT_REGISTRATION+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_COLLAB_EVENT_REGISTRATION](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_COLLAB_EVENT_REGISTRATION)
+[PEER_CONNECTION_INFO](https://www.google.com/search?num=5&q=PEER_CONNECTION_INFO+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_CONNECTION_INFO](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_CONNECTION_INFO)
+[PEER_CONTACT](https://www.google.com/search?num=5&q=PEER_CONTACT+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_CONTACT](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_CONTACT)
+[PEER_CREDENTIAL_INFO](https://www.google.com/search?num=5&q=PEER_CREDENTIAL_INFO+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_CREDENTIAL_INFO](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_CREDENTIAL_INFO)
+[PEER_DATA](https://www.google.com/search?num=5&q=PEER_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_DATA)
+[PEER_ENDPOINT](https://www.google.com/search?num=5&q=PEER_ENDPOINT+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_ENDPOINT](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_ENDPOINT)
+[PEER_EVENT_APPLICATION_CHANGED_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_APPLICATION_CHANGED_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_APPLICATION_CHANGED_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_APPLICATION_CHANGED_DATA)
+[PEER_EVENT_CONNECTION_CHANGE_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_CONNECTION_CHANGE_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_CONNECTION_CHANGE_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_CONNECTION_CHANGE_DATA)
+[PEER_EVENT_ENDPOINT_CHANGED_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_ENDPOINT_CHANGED_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_ENDPOINT_CHANGED_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_ENDPOINT_CHANGED_DATA)
+[PEER_EVENT_INCOMING_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_INCOMING_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_INCOMING_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_INCOMING_DATA)
+[PEER_EVENT_MEMBER_CHANGE_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_MEMBER_CHANGE_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_MEMBER_CHANGE_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_MEMBER_CHANGE_DATA)
+[PEER_EVENT_NODE_CHANGE_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_NODE_CHANGE_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_NODE_CHANGE_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_NODE_CHANGE_DATA)
+[PEER_EVENT_OBJECT_CHANGED_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_OBJECT_CHANGED_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_OBJECT_CHANGED_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_OBJECT_CHANGED_DATA)
+[PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA)
+[PEER_EVENT_PRESENCE_CHANGED_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_PRESENCE_CHANGED_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_PRESENCE_CHANGED_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_PRESENCE_CHANGED_DATA)
+[PEER_EVENT_RECORD_CHANGE_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_RECORD_CHANGE_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_RECORD_CHANGE_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_RECORD_CHANGE_DATA)
+[PEER_EVENT_REQUEST_STATUS_CHANGED_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_REQUEST_STATUS_CHANGED_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_REQUEST_STATUS_CHANGED_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_REQUEST_STATUS_CHANGED_DATA)
+[PEER_EVENT_SYNCHRONIZED_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_SYNCHRONIZED_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_SYNCHRONIZED_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_SYNCHRONIZED_DATA)
+[PEER_EVENT_WATCHLIST_CHANGED_DATA](https://www.google.com/search?num=5&q=PEER_EVENT_WATCHLIST_CHANGED_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_EVENT_WATCHLIST_CHANGED_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_EVENT_WATCHLIST_CHANGED_DATA)
+[PEER_GRAPH_EVENT_DATA](https://www.google.com/search?num=5&q=PEER_GRAPH_EVENT_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_GRAPH_EVENT_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_GRAPH_EVENT_DATA)
+[PEER_GRAPH_EVENT_REGISTRATION](https://www.google.com/search?num=5&q=PEER_GRAPH_EVENT_REGISTRATION+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_GRAPH_EVENT_REGISTRATION](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_GRAPH_EVENT_REGISTRATION)
+[PEER_GRAPH_PROPERTIES](https://www.google.com/search?num=5&q=PEER_GRAPH_PROPERTIES+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_GRAPH_PROPERTIES](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_GRAPH_PROPERTIES)
+[PEER_GROUP_EVENT_DATA](https://www.google.com/search?num=5&q=PEER_GROUP_EVENT_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_GROUP_EVENT_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_GROUP_EVENT_DATA)
+[PEER_GROUP_EVENT_REGISTRATION](https://www.google.com/search?num=5&q=PEER_GROUP_EVENT_REGISTRATION+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_GROUP_EVENT_REGISTRATION](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_GROUP_EVENT_REGISTRATION)
+[PEER_GROUP_PROPERTIES](https://www.google.com/search?num=5&q=PEER_GROUP_PROPERTIES+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_GROUP_PROPERTIES](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_GROUP_PROPERTIES)
+[PEER_INVITATION](https://www.google.com/search?num=5&q=PEER_INVITATION+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_INVITATION](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_INVITATION)
+[PEER_INVITATION_INFO](https://www.google.com/search?num=5&q=PEER_INVITATION_INFO+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_INVITATION_INFO](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_INVITATION_INFO)
+[PEER_INVITATION_RESPONSE](https://www.google.com/search?num=5&q=PEER_INVITATION_RESPONSE+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_INVITATION_RESPONSE](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_INVITATION_RESPONSE)
+[PEER_MEMBER](https://www.google.com/search?num=5&q=PEER_MEMBER+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_MEMBER](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_MEMBER)
+[PEER_NAME_PAIR](https://www.google.com/search?num=5&q=PEER_NAME_PAIR+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_NAME_PAIR](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_NAME_PAIR)
+[PEER_NODE_INFO](https://www.google.com/search?num=5&q=PEER_NODE_INFO+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_NODE_INFO](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_NODE_INFO)
+[PEER_OBJECT](https://www.google.com/search?num=5&q=PEER_OBJECT+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_OBJECT](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_OBJECT)
+[PEER_PEOPLE_NEAR_ME](https://www.google.com/search?num=5&q=PEER_PEOPLE_NEAR_ME+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_PEOPLE_NEAR_ME](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_PEOPLE_NEAR_ME)
+[PEER_PNRP_CLOUD_INFO](https://www.google.com/search?num=5&q=PEER_PNRP_CLOUD_INFO+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_PNRP_CLOUD_INFO](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_PNRP_CLOUD_INFO)
+[PEER_PNRP_ENDPOINT_INFO](https://www.google.com/search?num=5&q=PEER_PNRP_ENDPOINT_INFO+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_PNRP_ENDPOINT_INFO](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_PNRP_ENDPOINT_INFO)
+[PEER_PNRP_REGISTRATION_INFO](https://www.google.com/search?num=5&q=PEER_PNRP_REGISTRATION_INFO+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_PNRP_REGISTRATION_INFO](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_PNRP_REGISTRATION_INFO)
+[PEER_PRESENCE_INFO](https://www.google.com/search?num=5&q=PEER_PRESENCE_INFO+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_PRESENCE_INFO](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_PRESENCE_INFO)
+[PEER_RECORD](https://www.google.com/search?num=5&q=PEER_RECORD+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_RECORD](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_RECORD)
+[PEER_SECURITY_INTERFACE](https://www.google.com/search?num=5&q=PEER_SECURITY_INTERFACE+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_SECURITY_INTERFACE](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_SECURITY_INTERFACE)
+[PEER_VERSION_DATA](https://www.google.com/search?num=5&q=PEER_VERSION_DATA+site%3Adocs.microsoft.com) | p2p.h | [Vanara.PInvoke.P2P.PEER_VERSION_DATA](https://github.com/dahall/Vanara/search?l=C%23&q=PEER_VERSION_DATA)
diff --git a/PInvoke/P2P/P2P.Collab.cs b/PInvoke/P2P/P2P.Collab.cs
new file mode 100644
index 00000000..faafde95
--- /dev/null
+++ b/PInvoke/P2P/P2P.Collab.cs
@@ -0,0 +1,2587 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using Vanara.Extensions;
+using Vanara.InteropServices;
+using static Vanara.PInvoke.AdvApi32;
+using static Vanara.PInvoke.Crypt32;
+using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
+
+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);
+
+ ///
+ /// 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 IEnumerable 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 IEnumerable 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 IEnumerable 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 IEnumerable 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 IEnumerable 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 IEnumerable 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, 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);
+
+ /// 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);
+
+ ///
+ /// 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);
+
+ ///
+ /// 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);
+
+ ///
+ /// 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);
+
+ ///
+ /// 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);
+
+ ///
+ /// 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);
+
+ ///
+ /// 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);
+
+ /// 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 SafeHPEEREVENT 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 SafeHPEEREVENT : 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 SafeHPEEREVENT(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
+
+ /// Initializes a new instance of the class.
+ private SafeHPEEREVENT() : base() { }
+
+ /// Performs an implicit conversion from to .
+ /// The safe handle instance.
+ /// The result of the conversion.
+ public static implicit operator HPEEREVENT(SafeHPEEREVENT 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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/P2P/P2P.Funcs.cs b/PInvoke/P2P/P2P.Funcs.cs
new file mode 100644
index 00000000..5a6de499
--- /dev/null
+++ b/PInvoke/P2P/P2P.Funcs.cs
@@ -0,0 +1,666 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using Vanara.Extensions;
+using Vanara.InteropServices;
+using static Vanara.PInvoke.AdvApi32;
+using static Vanara.PInvoke.Crypt32;
+using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the P2P.dll
+ public static partial class P2P
+ {
+ ///
+ public const ushort PEER_COLLAB_VERSION = 0x0001;
+
+ ///
+ public const ushort PEER_GRAPH_VERSION = 0x0001;
+
+ ///
+ public const ushort PEER_GROUP_VERSION = 0x0101;
+
+ ///
+ public const ushort PNRP_VERSION = 0x0002;
+
+ ///
+ /// The PFNPEER_FREE_SECURITY_DATA callback specifies the function that the Peer Graphing Infrastructure calls to free data
+ /// returned by PFNPEER_SECURE_RECORD and PFNPEER_VALIDATE_RECORD callbacks.
+ ///
+ /// Specifies the peer graph associated with the specified record.
+ ///
+ /// Pointer to the security context to free. This parameter is set to the value of the pvContext member of the
+ /// PEER_SECURITY_INTERFACE structure passed in PeerGraphCreate or PeerGraphOpen.
+ ///
+ /// Pointer to the security data to free.
+ ///
+ /// If the callback is successful, the return value is S_OK. Otherwise, the callback returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ ///
+ ///
+ /// This callback can be invoked from any of the Peer Graphing API functions involving records, such as PeerGraphUpdateRecord.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nc-p2p-pfnpeer_free_security_data PFNPEER_FREE_SECURITY_DATA
+ // PfnpeerFreeSecurityData; HRESULT PfnpeerFreeSecurityData( HGRAPH hGraph, PVOID pvContext, PPEER_DATA pSecurityData ) {...}
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ [PInvokeData("p2p.h", MSDNShortId = "NC:p2p.PFNPEER_FREE_SECURITY_DATA")]
+ public delegate HRESULT PFNPEER_FREE_SECURITY_DATA(HGRAPH hGraph, [In, Optional] IntPtr pvContext, in PEER_DATA pSecurityData);
+
+ ///
+ /// Specifies the peer graph associated with the specified record.
+ ///
+ /// Pointer to the security context. This parameter should point to the pvContext member of the PEER_SECURITY_INTERFACE structure.
+ ///
+ /// If this callback succeeds, the return value is S_OK; otherwise, the error.
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ [PInvokeData("p2p.h")]
+ public delegate HRESULT PFNPEER_ON_PASSWORD_AUTH_FAILED(HGRAPH hGraph, [In, Optional] IntPtr pvContext);
+
+ ///
+ /// The PFNPEER_SECURE_RECORD callback specifies the function that the Peer Graphing Infrastructure calls to secure records.
+ ///
+ /// Specifies the peer graph associated with the specified record.
+ ///
+ /// Pointer to the security context. This parameter points to the pvContext member of the PEER_SECURITY_INTERFACE structure.
+ ///
+ /// Pointer to the record to secure.
+ /// Specifies the reason the validation must occur. PEER_RECORD_CHANGE_TYPE enumerates the valid values.
+ ///
+ /// If this callback succeeds, the return value is S_OK.
+ ///
+ ///
+ /// This callback is invoked whenever an application calls any of the methods that modify records, such as PeerGraphAddRecord or
+ /// PeerGraphUpdateRecord. This callback should create data that is specific to this record, such as a small digital signature, and
+ /// return it through the ppSecurityData parameter. This data is then added to the record in the securityData member, and is
+ /// verified by the method specified by the pfnValidateRecord member of the PEER_SECURITY_INTERFACE.
+ ///
+ ///
+ /// Note This process happens on the local computer as well as any peer connected to the graph when the peer receives the record.
+ ///
+ ///
+ /// If the operation specified by the changeType parameter is not allowed, the callback should return a failure code, such as
+ /// PEER_E_NOT_AUTHORIZED, instead of S_OK.
+ ///
+ /// This callback can be invoked from any of the Peer Graphing API functions involving records, such as PeerGraphUpdateRecord.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nc-p2p-pfnpeer_secure_record PFNPEER_SECURE_RECORD PfnpeerSecureRecord;
+ // HRESULT PfnpeerSecureRecord( HGRAPH hGraph, PVOID pvContext, PPEER_RECORD pRecord, PEER_RECORD_CHANGE_TYPE changeType, PPEER_DATA
+ // *ppSecurityData ) {...}
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ [PInvokeData("p2p.h", MSDNShortId = "NC:p2p.PFNPEER_SECURE_RECORD")]
+ public delegate HRESULT PFNPEER_SECURE_RECORD(HGRAPH hGraph, [In, Optional] IntPtr pvContext, in PEER_RECORD pRecord, PEER_RECORD_CHANGE_TYPE changeType, out PEER_DATA ppSecurityData);
+
+ ///
+ /// The PFNPEER_VALIDATE_RECORD callback specifies the function that the Peer Graphing Infrastructure calls to validate records.
+ ///
+ /// Specifies the peer graph associated with the specified record.
+ ///
+ /// Pointer to the security context. This parameter should point to the pvContext member of the PEER_SECURITY_INTERFACE structure.
+ ///
+ /// Specifies the record to validate.
+ /// Specifies the reason the validation must occur. Must be one of the PEER_RECORD_CHANGE_TYPE values.
+ ///
+ /// If this callback succeeds, the return value is S_OK; otherwise, the function returns one of the following errors:
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// PEER_E_DEFERRED_VALIDATION
+ ///
+ /// The specified record cannot be validated at this time because there is insufficient information to complete the operation.
+ /// Validation is deferred. Call PeerGraphValidateDeferredRecords when sufficient information is obtained.
+ ///
+ ///
+ /// -
+ /// PEER_E_INVALID_RECORD
+ /// The specified record is invalid.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// When this callback is called by the Peer Graphing Infrastructure, a PEER_RECORD_CHANGE_TYPE value is passed. This specifies the
+ /// operation just performed on the record. The application must verify the record based on the change type. If the application
+ /// requires more information to verify the record, it can return PEER_E_DEFERRED_VALIDATION and the Peer Graphing Infrastructure
+ /// places the record in a deferred-record list. Once the security mechanism has enough information to validate the record, it calls
+ /// PeerGraphValidateDeferredRecords, and any record in the deferred-record list is re-submitted for validation.
+ ///
+ /// This callback can be invoked from any of the Peer Graphing API functions involving records, such as PeerGraphUpdateRecord.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nc-p2p-pfnpeer_validate_record PFNPEER_VALIDATE_RECORD
+ // PfnpeerValidateRecord; HRESULT PfnpeerValidateRecord( HGRAPH hGraph, PVOID pvContext, PPEER_RECORD pRecord,
+ // PEER_RECORD_CHANGE_TYPE changeType ) {...}
+ [UnmanagedFunctionPointer(CallingConvention.Winapi)]
+ [PInvokeData("p2p.h", MSDNShortId = "NC:p2p.PFNPEER_VALIDATE_RECORD")]
+ public delegate HRESULT PFNPEER_VALIDATE_RECORD(HGRAPH hGraph, [In, Optional] IntPtr pvContext, in PEER_RECORD pRecord, PEER_RECORD_CHANGE_TYPE changeType);
+
+ ///
+ /// The PeerEndEnumeration function releases an enumeration, for example, a record or member enumeration, and deallocates all
+ /// resources associated with the enumeration.
+ ///
+ /// Handle to the enumeration to be released. This handle is generated by a peer enumeration function.
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns the following value.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// The parameter is not valid.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peerendenumeration NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerEndEnumeration( HPEERENUM hPeerEnum );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerEndEnumeration")]
+ public static extern HRESULT PeerEndEnumeration(HPEERENUM hPeerEnum);
+
+ ///
+ /// The PeerFreeData function deallocates a block of data and returns it to the memory pool. Use the PeerFreeData
+ /// function to free data that the Peer Identity Manager, Peer Grouping, and Peer Collaboration APIs return.
+ ///
+ /// Pointer to a block of data to be deallocated. This parameter must reference a valid block of memory.
+ /// There are no return values.
+ ///
+ /// Do not use this function to release memory that the Peer Graphing API returns. Use PeerGraphFreeData for memory that the Peer
+ /// Graphing API returns.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peerfreedata NOT_BUILD_WINDOWS_DEPRECATE VOID PeerFreeData( LPCVOID
+ // pvData );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerFreeData")]
+ public static extern void PeerFreeData(IntPtr pvData);
+
+ /// The PeerGetItemCount function returns a count of the items in a peer enumeration.
+ ///
+ /// Handle to the peer enumeration on which a count is performed. A peer enumeration function generates this handle.
+ ///
+ /// Returns the total number of items in a peer enumeration.
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergetitemcount NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGetItemCount( HPEERENUM hPeerEnum, ULONG *pCount );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGetItemCount")]
+ public static extern HRESULT PeerGetItemCount(HPEERENUM hPeerEnum, out uint pCount);
+
+ /// The PeerGetNextItem function returns a specific number of items from a peer enumeration.
+ ///
+ /// Handle to the peer enumeration from which items are retrieved. This handle is generated by a peer enumeration function.
+ ///
+ ///
+ /// Pointer to an integer that specifies the number of items to be retrieved from the peer enumeration. When returned, it contains
+ /// the number of items in ppvItems. This parameter cannot be NULL.
+ ///
+ ///
+ /// Receives a pointer to an array of pointers to the next pCount items in the peer enumeration. The data, for example, a record or
+ /// member information block, depends on the actual peer enumeration type.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform a specified operation.
+ ///
+ ///
+ ///
+ ///
+ /// The PeerGetNextItem function returns the following:
+ ///
+ /// -
+ /// Items that are equal to or less than the amount specified in pCount.
+ ///
+ /// -
+ /// A list of items that are less than the amount specified when the amount is greater than the number of items available.
+ ///
+ ///
+ ///
+ /// Note For example, when the inbound value of pCount is 10 and the remainder of the enumeration is 5 items, only 5 items
+ /// are returned and the value pointed to by pCount is set to 5.
+ ///
+ /// All items returned must be freed by passing a pointer to the array of pointers to the PeerFreeData function.
+ /// The end of an enumeration is indicated when the function returns with the pCount parameter set to zero (0).
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergetnextitem NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGetNextItem( HPEERENUM hPeerEnum, ULONG *pCount, PVOID **pppvItems );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGetNextItem")]
+ public static extern HRESULT PeerGetNextItem([In] HPEERENUM hPeerEnum, ref uint pCount, out SafePeerData pppvItems);
+
+ ///
+ /// The PeerGraphShutdown function cleans up any resources allocated by the call to PeerGraphStartup. There must be a call to
+ /// PeerGraphShutdown for each call to PeerGraphStartup.
+ ///
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds; otherwise, the function returns the one of the standard error codes defined in
+ /// WinError.h, or the function returns the following value:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// PEER_E_NOT_INITIALIZED
+ /// The peer graph must be initialized with a call to PeerGraphStartup before using this function.
+ ///
+ ///
+ ///
+ ///
+ /// When the last PeerGraphShutdown is called for a peer graph, all the opened peer graphs, outstanding enumeration handles,
+ /// and outstanding event registration handles are automatically released.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergraphshutdown NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerGraphShutdown();
+ [DllImport(Lib_P2PGraph, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGraphShutdown")]
+ public static extern HRESULT PeerGraphShutdown();
+
+ ///
+ /// The PeerGraphStartup function indicates to the Peer Graphing Infrastructure what version of the Peer protocols the
+ /// calling application requires. PeerGraphStartup must be called before any other peer graphing functions. It must be
+ /// matched by a call to PeerGraphShutdown.
+ ///
+ /// Specify PEER_GRAPH_VERSION.
+ ///
+ /// Pointer to a PEER_VERSION_DATA structure that receives the version of the Peer Infrastructure installed on the local computer.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds; otherwise, the function returns one of the following values:
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_UNSUPPORTED_VERSION
+ /// The version requested is not supported by the Peer Infrastructure .dll installed on the local computer.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergraphstartup NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGraphStartup( WORD wVersionRequested, PPEER_VERSION_DATA pVersionData );
+ [DllImport(Lib_P2PGraph, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGraphStartup")]
+ public static extern HRESULT PeerGraphStartup(ushort wVersionRequested, out PEER_VERSION_DATA pVersionData);
+
+ ///
+ /// The PeerHostNameToPeerName function decodes a host name returned by PeerNameToPeerHostName into the peer name string it represents.
+ ///
+ /// Pointer to a zero-terminated Unicode string that contains the host name to decode.
+ ///
+ /// Pointer to the address of the zero-terminated Unicode string that contains the decoded peer name. The returned string must be
+ /// released with PeerFreeData.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peerhostnametopeername NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerHostNameToPeerName( PCWSTR pwzHostName, PWSTR *ppwzPeerName );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerHostNameToPeerName")]
+ public static extern HRESULT PeerHostNameToPeerName([MarshalAs(UnmanagedType.LPWStr)] string pwzHostName,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzPeerName);
+
+ ///
+ /// The PeerNameToPeerHostName function encodes the supplied peer name as a format that can be used with a subsequent call to
+ /// the getaddrinfo Windows Sockets function.
+ ///
+ /// Pointer to a zero-terminated Unicode string that contains the peer name to encode as a host name.
+ ///
+ /// Pointer to the address of the zero-terminated Unicode string that contains the encoded host name. This string can be passed to
+ /// getaddrinfo_v2 to obtain network information about the peer.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peernametopeerhostname NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerNameToPeerHostName( PCWSTR pwzPeerName, PWSTR *ppwzHostName );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerNameToPeerHostName")]
+ public static extern HRESULT PeerNameToPeerHostName([MarshalAs(UnmanagedType.LPWStr)] string pwzPeerName,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzHostName);
+
+ ///
+ /// The PeerPnrpShutdown function shuts down a running instance of the Peer Name Resolution Protocol (PNRP) service and
+ /// releases all resources associated with it.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// PEER_E_NOT_INITIALIZED
+ /// The Windows Peer infrastructure is not initialized. Calling the relevant initialization function is required.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peerpnrpshutdown NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerPnrpShutdown();
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerPnrpShutdown")]
+ public static extern HRESULT PeerPnrpShutdown();
+
+ /// The PeerPnrpStartup function starts the Peer Name Resolution Protocol (PNRP) service for the calling peer.
+ /// The version of PNRP to use for this service instance. The default value is PNRP_VERSION (2).
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_UNSUPPORTED_VERSION
+ /// The provided version is unsupported.
+ ///
+ /// -
+ /// PEER_E_SERVICE_NOT_AVAILABLE
+ ///
+ /// The Peer Collaboration infrastructure, which includes People Near Me, is not available. This code will also be returned whenever
+ /// an attempt is made to utilize the Collaboration infrastructure from an elevated process.
+ ///
+ ///
+ ///
+ ///
+ /// To shutdown the PNRP service for the calling peer and release all resources associated with it, call PeerPnrpShutdown.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peerpnrpstartup NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerPnrpStartup( WORD wVersionRequested );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerPnrpStartup")]
+ public static extern HRESULT PeerPnrpStartup(ushort wVersionRequested = PNRP_VERSION);
+
+ private static IEnumerable PeerEnum(TIn p1, Func setup) where T : struct where TIn : struct =>
+ PeerEnum(() => setup(p1));
+
+ private static IEnumerable PeerEnum(Func setup) where T : struct
+ {
+ using var hEnum = setup();
+ if (hEnum.IsInvalid) return new T[0];
+ PeerGetItemCount(hEnum, out var count).ThrowIfFailed();
+ if (count == 0) return new T[0];
+ PeerGetNextItem(hEnum, ref count, out var items).ThrowIfFailed();
+ using (items)
+ return items.DangerousGetHandle().ToArray((int)count);
+ }
+
+ /// Provides a handle to a peer enumeration.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HPEERENUM : IHandle
+ {
+ private IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HPEERENUM(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HPEERENUM NULL => new HPEERENUM(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(HPEERENUM h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HPEERENUM(IntPtr h) => new HPEERENUM(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HPEERENUM h1, HPEERENUM h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HPEERENUM h1, HPEERENUM h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HPEERENUM h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// Provides a for that is disposed using .
+ public class SafeHPEERENUM : 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 SafeHPEERENUM(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
+
+ /// Initializes a new instance of the class.
+ private SafeHPEERENUM() : base() { }
+
+ /// Performs an implicit conversion from to .
+ /// The safe handle instance.
+ /// The result of the conversion.
+ public static implicit operator HPEERENUM(SafeHPEERENUM h) => h.handle;
+
+ ///
+ protected override bool InternalReleaseHandle() => PeerEndEnumeration(handle).Succeeded;
+ }
+
+ /// Provides a for data that is disposed using .
+ public class SafePeerData : SafeHANDLE
+ {
+ /// Initializes a new instance of the class.
+ protected SafePeerData() : base() { }
+
+ ///
+ protected override bool InternalReleaseHandle() { PeerFreeData(handle); return true; }
+ }
+
+ internal class PeerStringMarshaler : ICustomMarshaler
+ {
+ internal PeerStringMarshaler()
+ {
+ }
+
+ public static ICustomMarshaler GetInstance(string _) => new PeerStringMarshaler();
+
+ /// Performs necessary cleanup of the managed data when it is no longer needed.
+ /// The managed object to be destroyed.
+ public void CleanUpManagedData(object ManagedObj) { }
+
+ /// Performs necessary cleanup of the unmanaged data when it is no longer needed.
+ /// A pointer to the unmanaged data to be destroyed.
+ public void CleanUpNativeData(IntPtr pNativeData) => PeerFreeData(pNativeData);
+
+ /// Returns the size of the native data to be marshaled.
+ /// The size in bytes of the native data.
+ public int GetNativeDataSize() => -1;
+
+ /// Converts the managed data to unmanaged data.
+ /// The managed object to be converted.
+ /// Returns the COM view of the managed object.
+ public IntPtr MarshalManagedToNative(object ManagedObj) => throw new NotImplementedException();
+
+ /// Converts the unmanaged data to managed data.
+ /// A pointer to the unmanaged data to be wrapped.
+ /// Returns the managed view of the COM data.
+ public object MarshalNativeToManaged(IntPtr pNativeData) => Marshal.PtrToStringUni(pNativeData);
+ }
+
+ internal class PeerStructMarshaler : ICustomMarshaler where T : struct
+ {
+ internal PeerStructMarshaler()
+ {
+ }
+
+ public static ICustomMarshaler GetInstance(string _) => new PeerStructMarshaler();
+
+ /// Performs necessary cleanup of the managed data when it is no longer needed.
+ /// The managed object to be destroyed.
+ public void CleanUpManagedData(object ManagedObj) { }
+
+ /// Performs necessary cleanup of the unmanaged data when it is no longer needed.
+ /// A pointer to the unmanaged data to be destroyed.
+ public void CleanUpNativeData(IntPtr pNativeData) => PeerFreeData(pNativeData);
+
+ /// Returns the size of the native data to be marshaled.
+ /// The size in bytes of the native data.
+ public int GetNativeDataSize() => -1;
+
+ /// Converts the managed data to unmanaged data.
+ /// The managed object to be converted.
+ /// Returns the COM view of the managed object.
+ public IntPtr MarshalManagedToNative(object ManagedObj) => throw new NotImplementedException();
+
+ /// Converts the unmanaged data to managed data.
+ /// A pointer to the unmanaged data to be wrapped.
+ /// Returns the managed view of the COM data.
+ public object MarshalNativeToManaged(IntPtr pNativeData) => Marshal.PtrToStructure(pNativeData, typeof(T));
+ }
+
+ /*
+PeerPnrpEndResolve
+PeerPnrpGetCloudInfo
+PeerPnrpGetEndpoint
+PeerPnrpRegister
+PeerPnrpResolve
+PeerPnrpStartResolve
+PeerPnrpUnregister
+PeerPnrpUpdateRegistration
+PeerGraphAddRecord
+PeerGraphClose
+PeerGraphCloseDirectConnection
+PeerGraphConnect
+PeerGraphCreate
+PeerGraphDelete
+PeerGraphDeleteRecord
+PeerGraphEndEnumeration
+PeerGraphEnumConnections
+PeerGraphEnumNodes
+PeerGraphEnumRecords
+PeerGraphExportDatabase
+PeerGraphFreeData
+PeerGraphGetEventData
+PeerGraphGetItemCount
+PeerGraphGetNextItem
+PeerGraphGetNodeInfo
+PeerGraphGetProperties
+PeerGraphGetRecord
+PeerGraphGetStatus
+PeerGraphImportDatabase
+PeerGraphListen
+PeerGraphOpen
+PeerGraphOpenDirectConnection
+PeerGraphPeerTimeToUniversalTime
+PeerGraphRegisterEvent
+PeerGraphSearchRecords
+PeerGraphSendData
+PeerGraphSetNodeAttributes
+PeerGraphSetPresence
+PeerGraphSetProperties
+PeerGraphUniversalTimeToPeerTime
+PeerGraphUnregisterEvent
+PeerGraphUpdateRecord
+PeerGraphValidateDeferredRecords
+*/
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/P2P/P2P.Group.cs b/PInvoke/P2P/P2P.Group.cs
new file mode 100644
index 00000000..9899543d
--- /dev/null
+++ b/PInvoke/P2P/P2P.Group.cs
@@ -0,0 +1,2617 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using Vanara.Extensions;
+using Vanara.InteropServices;
+using static Vanara.PInvoke.AdvApi32;
+using static Vanara.PInvoke.Crypt32;
+using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the P2P.dll
+ public static partial class P2P
+ {
+ ///
+ /// The PeerGroupAddRecord function adds a new record to the peer group, which is propagated to all participating peers.
+ ///
+ ///
+ /// Handle to the peer group. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or PeerGroupJoin function. This
+ /// parameter is required.
+ ///
+ ///
+ /// Pointer to a PEER_RECORD structure that is added to the peer group specified in hGroup. This parameter is required.
+ /// The following members in PEER_RECORD must be populated.
+ ///
+ /// -
+ /// dwSize
+ ///
+ /// -
+ /// type
+ ///
+ /// -
+ /// ftExpiration
+ ///
+ ///
+ /// ftExpiration
+ /// must be expressed as peer time (see
+ /// PeerGroupUniversalTimeToPeerTime
+ /// ).
+ /// The following members are ignored and overwritten if populated.
+ ///
+ /// -
+ /// id
+ ///
+ /// -
+ /// pwzCreatorId
+ ///
+ /// -
+ /// pwzLastModifiedById
+ ///
+ /// -
+ /// ftCreation
+ ///
+ /// -
+ /// ftLastModified
+ ///
+ /// -
+ /// securityData
+ ///
+ ///
+ /// The remaining fields are optional.
+ ///
+ /// Pointer to a GUID that identifies the record. This parameter is required.
+ ///
+ /// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The peer group is not in a state where records can be added. For example, PeerGroupJoin is called, but synchronization with the
+ /// peer group database has not completed.
+ ///
+ ///
+ /// -
+ /// PEER_E_INVALID_ATTRIBUTES
+ ///
+ /// The XML string that contains the record attributes in the pwzAttributes member of the PEER_RECORD structure does not comply with
+ /// the schema specification.
+ ///
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ /// -
+ /// PEER_E_INVALID_PEER_NAME
+ /// The supplied peer name is invalid.
+ ///
+ /// -
+ /// PEER_E_INVALID_RECORD
+ /// One or more fields in PEER_RECORD are invalid.
+ ///
+ /// -
+ /// PEER_E_MAX_RECORD_SIZE_EXCEEDED
+ /// The record has exceeded the maximum size allowed by the peer group properties.
+ ///
+ /// -
+ /// PEER_E_NOT_AUTHORIZED
+ /// The identity is not authorized to publish a record of that type.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupaddrecord NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupAddRecord( HGROUP hGroup, PPEER_RECORD pRecord, GUID *pRecordId );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupAddRecord")]
+ public static extern HRESULT PeerGroupAddRecord(HGROUP hGroup, in PEER_RECORD pRecord, out Guid pRecordId);
+
+ ///
+ /// The PeerGroupClose function invalidates the peer group handle obtained by a previous call to the PeerGroupCreate,
+ /// PeerGroupJoin, or PeerGroupOpen function.
+ ///
+ ///
+ /// Handle to the peer group to close. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or PeerGroupJoin function.
+ /// This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns the following value.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// If the peer group handle closed is the last handle that refers to a peer group shared across multiple applications or processes,
+ /// the call also closes the respective network connections for the peer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupclose NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerGroupClose(
+ // HGROUP hGroup );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupClose")]
+ public static extern HRESULT PeerGroupClose(HGROUP hGroup);
+
+ /// The PeerGroupCloseDirectConnection function closes a specific direct connection between two peers.
+ ///
+ /// Handle to the peer group that contains the peers involved in the direct connection. This handle is returned by the
+ /// PeerGroupCreate, PeerGroupOpen, or PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Specifies the connection ID to disconnect from. This parameter is required and has no default value.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// PEER_E_CONNECTION_NOT_FOUND
+ /// A direct connection that matches the supplied connection ID cannot be found.
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupclosedirectconnection NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupCloseDirectConnection( HGROUP hGroup, ULONGLONG ullConnectionId );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupCloseDirectConnection")]
+ public static extern HRESULT PeerGroupCloseDirectConnection(HGROUP hGroup, ulong ullConnectionId);
+
+ ///
+ /// The PeerGroupConnect function initiates a PNRP search for a peer group and attempts to connect to it. After this function
+ /// is called successfully, a peer can communicate with other members of the peer group.
+ ///
+ ///
+ /// Handle to the peer group to which a peer intends to connect. This handle is returned by the PeerGroupCreate,
+ /// PeerGroupOpen,PeerGroupJoin, or PeerGroupPasswordJoin function. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns the following value.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ ///
+ /// An application registers for peer events before calling this function. If the function call is unsuccessful, a
+ /// PEER_GROUP_EVENT_CONNECTION_FAILED event is raised. Otherwise, a PEER_GROUP_EVENT_STATUS_CHANGED event is raised.
+ ///
+ ///
+ /// The PEER_GROUP_EVENT_CONNECTION_FAILED event is also raised when a group creator fails to call PeerGroupConnect
+ /// immediately after creation. If this does not take place, users given an invitation will call PeerGroupConnect
+ /// successfully but they will not be able to listen and will eventually receive the connection failed event.
+ ///
+ ///
+ /// In the event of a clock skew between participating machines, the success of PeerGroupConnect may depend on the severity
+ /// of the skew. When troubleshooting a failure to join, this possibility should be taken into consideration by verifying that the
+ /// machine clocks are synchronized.
+ ///
+ /// To be present in the peer group and receive events but remain unconnected, use the PeerGroupOpen function.
+ ///
+ /// If a time-out value for PeerGroupConnect is not provided in the application, encountering a failure will cause the
+ /// application to hang. A time-out value of 30 seconds is recommended.
+ ///
+ ///
+ /// Prior to calling PeerGroupConnect, a group exists in a ' Disconnected State'. During this time the group cannot be
+ /// detected or receive connections. In order to return a group to this state, the PeerGroupClose function must be called.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupconnect NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupConnect( HGROUP hGroup );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupConnect")]
+ public static extern HRESULT PeerGroupConnect(HGROUP hGroup);
+
+ ///
+ /// The PeerGroupConnectByAddress function attempts to connect to the peer group that other peers with known IPv6 addresses
+ /// are participating in. After this function is called successfully, a peer can communicate with other members of the peer group.
+ ///
+ ///
+ /// Handle to the peer group to which a peer intends to connect. This handle is returned by the PeerGroupCreate,
+ /// PeerGroupOpen,PeerGroupJoin, or PeerGroupPasswordJoin function. This parameter is required.
+ ///
+ /// The total number of PEER_ADDRESS structures pointed to by pAddresses.
+ ///
+ /// Pointer to a list of PEER_ADDRESS structures that specify the endpoints of peers participating in the group.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns the following value.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors may be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// If a time-out value for PeerGroupConnectByAddress is not provided in the application, encountering a failure will cause the
+ /// application to hang. A time-out value of 30 seconds is recommended.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupconnectbyaddress NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupConnectByAddress( HGROUP hGroup, ULONG cAddresses, PPEER_ADDRESS pAddresses );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupConnectByAddress")]
+ public static extern HRESULT PeerGroupConnectByAddress(HGROUP hGroup, uint cAddresses, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] PEER_ADDRESS[] pAddresses);
+
+ /// The PeerGroupCreate function creates a new peer group.
+ ///
+ ///
+ /// Pointer to a PEER_GROUP_PROPERTIES structure that specifies the specific details of the group, such as the peer group names,
+ /// invitation lifetimes, and presence lifetimes. This parameter is required.
+ ///
+ /// The following members must be set:
+ ///
+ /// -
+ /// pwzCreatorPeerName
+ ///
+ ///
+ /// The following members cannot be set:
+ ///
+ /// -
+ /// pwzGroupPeerName
+ ///
+ ///
+ /// The remaining members are optional.
+ ///
+ ///
+ /// Returns the handle pointer to the peer group. Any function called with this handle as a parameter has the corresponding action
+ /// performed on that peer group. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_CLOUD_NAME_AMBIGUOUS
+ /// The cloud specified in pProperties cannot be uniquely discovered (more than one cloud matches the provided name).
+ ///
+ /// -
+ /// PEER_E_INVALID_CLASSIFIER
+ /// The peer group classifier specified in pProperties is invalid.
+ ///
+ /// -
+ /// PEER_E_INVALID_PEER_NAME
+ /// The peer name specified for the group in pProperties is invalid.
+ ///
+ /// -
+ /// PEER_E_INVALID_PROPERTIES
+ /// One or more of the peer group properties supplied in pProperties is invalid.
+ ///
+ /// -
+ /// PEER_E_NO_CLOUD
+ /// The cloud specified in pProperties cannot be located.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the identity or group keys is denied. Typically, this is caused by an incorrect access control list (ACL) for the
+ /// folder that contains the user or computer keys. This can happen when the ACL is reset manually.
+ ///
+ ///
+ /// -
+ /// PEER_E_PASSWORD_DOES_NOT_MEET_POLICY
+ /// Password specified does not meet system password requirements.
+ ///
+ /// -
+ /// ERROR_DELETE_PENDING
+ /// The peer identity specified as the Group Creator has been deleted or is in the process of being deleted.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ ///
+ /// PeerGroupConnect must be called by the group creator immediately after creation. If this does not take place, users given an
+ /// invitation will call PeerGroupConnect successfully but they will not be able to listen and will eventually receive the
+ /// connection failed event.
+ ///
+ ///
+ /// An application obtains an identity by calling PeerIdentityCreate, or any other method that returns an identity name string. This
+ /// identity serves as the owner of the group, and is the initial member of the peer group when created.
+ ///
+ ///
+ /// For applications that utilize passwords, it is recommended the passwords are handled securely by calling the CryptoProtectMemory
+ /// and SecureZeroMemory functions.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupcreate NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupCreate( PPEER_GROUP_PROPERTIES pProperties, HGROUP *phGroup );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupCreate")]
+ public static extern HRESULT PeerGroupCreate(in PEER_GROUP_PROPERTIES pProperties, out HGROUP phGroup);
+
+ ///
+ /// The PeerGroupCreateInvitation function returns an XML string that can be used by the specified peer to join a group.
+ ///
+ ///
+ /// Handle to the peer group for which this invitation is issued. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the XML blob (including the GMC) returned by a previous call to PeerIdentityGetXML
+ /// with the identity of the peer. Alternatively, this parameter can contain a pointer to an XML blob generated by
+ /// PeerIdentityGetXML using the peer information contained in PEER_CONTACT to generate an invitation for a peer contact.
+ ///
+ ///
+ /// Specifies a UTC FILETIME structure that contains the specific date and time the invitation expires. This value cannot be greater
+ /// than the remaining lifetime of the issuing peer. If this parameter is NULL, the invitation lifetime is set to the maximum
+ /// value possible - the remaining lifetime of the peer.
+ ///
+ /// Specifies the count of roles in pRoleInfo.
+ ///
+ /// Pointer to a list of GUIDs that specifies the combined set of available roles. The available roles are as follows.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_GROUP_ROLE_ADMIN
+ ///
+ /// This role can issue invitations, issue credentials, and renew the GMC of other administrators, as well as behave as a member of
+ /// the peer group.
+ ///
+ ///
+ /// -
+ /// PEER_GROUP_ROLE_MEMBER
+ /// This role can publish records to the group database.
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the invitation from the issuer. This invitation can be passed to PeerGroupJoin by the
+ /// recipient in order to join the specified peer group. To return the details of the invitation as a PEER_INVITATION_INFO
+ /// structure, pass this string to PeerGroupParseInvitation. To release this data, pass this pointer to PeerFreeData.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds; otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The peer group is not in a state where records can be added. For example, PeerGroupJoin is called, but synchronization with the
+ /// group database has not completed.
+ ///
+ ///
+ /// -
+ /// PEER_E_CHAIN_TOO_LONG
+ ///
+ /// The GMC chain is longer than 24 administrators or members. For more information about GMC chains, please refer to the How Group
+ /// Security Works documentation.
+ ///
+ ///
+ /// -
+ /// PEER_E_IDENTITY_DELETED
+ /// The data passed as pwzIdentityInfo is for a deleted identity and no longer valid.
+ ///
+ /// -
+ /// PEER_E_NOT_AUTHORIZED
+ /// The peer that called this method is not an administrator.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL) for the
+ /// folder that contains the user or computer keys. This can happen when the ACL is reset manually.
+ ///
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// Peers cannot create invitations for peers whose assumed role is superior to their own. For example, a peer in a member role
+ /// cannot create an invitation for a peer in an administrator role.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupcreateinvitation NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupCreateInvitation( HGROUP hGroup, PCWSTR pwzIdentityInfo, FILETIME *pftExpiration, ULONG cRoles, const GUID *pRoles,
+ // PWSTR *ppwzInvitation );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupCreateInvitation")]
+ public static extern HRESULT PeerGroupCreateInvitation(HGROUP hGroup, [MarshalAs(UnmanagedType.LPWStr)] string pwzIdentityInfo, in FILETIME pftExpiration,
+ uint cRoles, [In, MarshalAs(UnmanagedType.LPArray)] Guid[] pRoles,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzInvitation);
+
+ ///
+ /// The PeerGroupCreateInvitation function returns an XML string that can be used by the specified peer to join a group.
+ ///
+ ///
+ /// Handle to the peer group for which this invitation is issued. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the XML blob (including the GMC) returned by a previous call to PeerIdentityGetXML
+ /// with the identity of the peer. Alternatively, this parameter can contain a pointer to an XML blob generated by
+ /// PeerIdentityGetXML using the peer information contained in PEER_CONTACT to generate an invitation for a peer contact.
+ ///
+ ///
+ /// Specifies a UTC FILETIME structure that contains the specific date and time the invitation expires. This value cannot be greater
+ /// than the remaining lifetime of the issuing peer. If this parameter is NULL, the invitation lifetime is set to the maximum
+ /// value possible - the remaining lifetime of the peer.
+ ///
+ /// Specifies the count of roles in pRoleInfo.
+ ///
+ /// Pointer to a list of GUIDs that specifies the combined set of available roles. The available roles are as follows.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_GROUP_ROLE_ADMIN
+ ///
+ /// This role can issue invitations, issue credentials, and renew the GMC of other administrators, as well as behave as a member of
+ /// the peer group.
+ ///
+ ///
+ /// -
+ /// PEER_GROUP_ROLE_MEMBER
+ /// This role can publish records to the group database.
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the invitation from the issuer. This invitation can be passed to PeerGroupJoin by the
+ /// recipient in order to join the specified peer group. To return the details of the invitation as a PEER_INVITATION_INFO
+ /// structure, pass this string to PeerGroupParseInvitation. To release this data, pass this pointer to PeerFreeData.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds; otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The peer group is not in a state where records can be added. For example, PeerGroupJoin is called, but synchronization with the
+ /// group database has not completed.
+ ///
+ ///
+ /// -
+ /// PEER_E_CHAIN_TOO_LONG
+ ///
+ /// The GMC chain is longer than 24 administrators or members. For more information about GMC chains, please refer to the How Group
+ /// Security Works documentation.
+ ///
+ ///
+ /// -
+ /// PEER_E_IDENTITY_DELETED
+ /// The data passed as pwzIdentityInfo is for a deleted identity and no longer valid.
+ ///
+ /// -
+ /// PEER_E_NOT_AUTHORIZED
+ /// The peer that called this method is not an administrator.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL) for the
+ /// folder that contains the user or computer keys. This can happen when the ACL is reset manually.
+ ///
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// Peers cannot create invitations for peers whose assumed role is superior to their own. For example, a peer in a member role
+ /// cannot create an invitation for a peer in an administrator role.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupcreateinvitation NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupCreateInvitation( HGROUP hGroup, PCWSTR pwzIdentityInfo, FILETIME *pftExpiration, ULONG cRoles, const GUID *pRoles,
+ // PWSTR *ppwzInvitation );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupCreateInvitation")]
+ public static extern HRESULT PeerGroupCreateInvitation(HGROUP hGroup, [MarshalAs(UnmanagedType.LPWStr)] string pwzIdentityInfo, [In, Optional] IntPtr pftExpiration,
+ uint cRoles, [In, MarshalAs(UnmanagedType.LPArray)] Guid[] pRoles,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzInvitation);
+
+ ///
+ /// The PeerGroupCreatePasswordInvitation function returns an XML string that can be used by the specified peer to join a
+ /// group with a matching password.
+ ///
+ ///
+ /// Handle to the peer group for which this invitation is issued. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the invitation from the issuer. This invitation can be passed to PeerGroupPasswordJoin
+ /// by the recipient in order to join the specified peer group. To return the details of the invitation as a PEER_INVITATION_INFO
+ /// structure, pass this string to PeerGroupParseInvitation. To release this data, pass this pointer to PeerFreeData.
+ ///
+ /// This function requires that the following fields are set on the
+ /// PEER_GROUP_PROPERTIES
+ /// structure passed to
+ /// PeerGroupCreate
+ /// .
+ ///
+ /// -
+ /// pwzGroupPassword. This field must contain the password used to validate peers joining the peer group.
+ ///
+ /// -
+ ///
+ /// groupPasswordRole. This field must containing the GUID of the role (administrator or peer) for which the password is required.
+ ///
+ ///
+ /// -
+ ///
+ /// dwAuthenticationSchemes. This field must have the PEER_GROUP_PASSWORD_AUTHENTICATION flag (0x00000001) set on it.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds; otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The peer group is not in a state where records can be added. For example, PeerGroupJoin is called, but synchronization with the
+ /// group database has not completed.
+ ///
+ ///
+ /// -
+ /// PEER_E_CHAIN_TOO_LONG
+ ///
+ /// The GMC chain is longer than 24 administrators or members. For more information about GMC chains, please refer to the How Group
+ /// Security Works documentation.
+ ///
+ ///
+ /// -
+ /// PEER_E_IDENTITY_DELETED
+ /// The data passed as pwzIdentityInfo is for a deleted identity and no longer valid.
+ ///
+ /// -
+ /// PEER_E_NOT_AUTHORIZED
+ /// The peer that called this method is not an administrator.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL) for the
+ /// folder that contains the user or computer keys. This can happen when the ACL is reset manually.
+ ///
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors may be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupcreatepasswordinvitation NOT_BUILD_WINDOWS_DEPRECATE
+ // HRESULT PeerGroupCreatePasswordInvitation( HGROUP hGroup, PWSTR *ppwzInvitation );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupCreatePasswordInvitation")]
+ public static extern HRESULT PeerGroupCreatePasswordInvitation(HGROUP hGroup,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzInvitation);
+
+ /// The PeerGroupDelete function deletes the local data and certificate associated with a peer group.
+ ///
+ /// Pointer to a Unicode string that contains the identity opening the specified peer group. If this parameter is NULL, the
+ /// implementation uses the identity obtained from PeerIdentityGetDefault.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the peer name of the peer group for which data is deleted. This parameter is required.
+ /// The group name can be obtained by calling PeerGroupGetProperties prior to PeerGroupClose, or by parsing the invitation with PeerGroupParseInvitation.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ /// Note If a delete operation fails due to a file system error, the appropriate file system error is returned.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_ACCESSDENIED
+ ///
+ /// Access to the peer group database is denied. Ensure that the peer has permission to perform this operation. In this case, the
+ /// peer must be the original creator of the peer group.
+ ///
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is invalid.
+ ///
+ /// -
+ /// PEER_E_NOT_FOUND
+ /// The peer group cannot be found.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL) for the
+ /// folder that contains the user or computer keys. This can happen when the ACL is reset manually.
+ ///
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// If a peer group is deleted, all handles associated with that group immediately become invalid. As a best practice, ensure that
+ /// all handles for this group are closed before calling this function. Otherwise, this data is deleted from all other running peer
+ /// applications that use it, which can cause errors and instability.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupdelete NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupDelete( PCWSTR pwzIdentity, PCWSTR pwzGroupPeerName );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupDelete")]
+ public static extern HRESULT PeerGroupDelete([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, [MarshalAs(UnmanagedType.LPWStr)] string pwzGroupPeerName);
+
+ ///
+ /// The PeerGroupDeleteRecord function deletes a record from a peer group. The creator, as well as any other member in an
+ /// administrative role may delete a specific record.
+ ///
+ ///
+ /// Handle to the peer group that contains the record. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ /// Specifies the GUID value that uniquely identifies the record to be deleted. This parameter is required.
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The peer group is not in a state where records can be deleted. For example, PeerGroupJoin is called, but synchronization with
+ /// the peer group database has not completed.
+ ///
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ /// -
+ /// PEER_E_NOT_AUTHORIZED
+ ///
+ /// The current identity does not have the authorization to delete the record. In this case, the identity is not the creator or a
+ /// member in an administrative role may delete a specific record.
+ ///
+ ///
+ /// -
+ /// PEER_E_RECORD_NOT_FOUND
+ /// The record cannot be located in the data store.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupdeleterecord NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupDeleteRecord( HGROUP hGroup, const GUID *pRecordId );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupDeleteRecord")]
+ public static extern HRESULT PeerGroupDeleteRecord(HGROUP hGroup, in Guid pRecordId);
+
+ /// The PeerGroupEnumConnections function creates an enumeration of connections currently active on the peer.
+ ///
+ /// Handle to the group that contains the connections to be enumerated. This handle is returned by the PeerGroupCreate,
+ /// PeerGroupOpen, or PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Specifies the flags that indicate the type of connection to enumerate. Valid values are specified by PEER_CONNECTION_FLAGS.
+ ///
+ ///
+ /// Pointer to the enumeration that contains the returned list of active connections. This handle is passed to PeerGetNextItem to
+ /// retrieve the items, with each item represented as a pointer to a PEER_CONNECTION_INFO structure. When finished,
+ /// PeerEndEnumeration is called to return the memory used by the enumeration. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupenumconnections NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupEnumConnections( HGROUP hGroup, DWORD dwFlags, HPEERENUM *phPeerEnum );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupEnumConnections")]
+ public static extern HRESULT PeerGroupEnumConnections(HGROUP hGroup, PEER_CONNECTION_FLAGS dwFlags, out SafeHPEERENUM phPeerEnum);
+
+ /// The PeerGroupEnumConnections function creates an enumeration of connections currently active on the peer.
+ ///
+ /// Handle to the group that contains the connections to be enumerated. This handle is returned by the PeerGroupCreate,
+ /// PeerGroupOpen, or PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Specifies the flags that indicate the type of connection to enumerate. Valid values are specified by PEER_CONNECTION_FLAGS.
+ ///
+ ///
+ /// The enumeration that contains the returned list of active connections, with each item represented as a pointer to a
+ /// PEER_CONNECTION_INFO structure.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupenumconnections NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupEnumConnections( HGROUP hGroup, DWORD dwFlags, HPEERENUM *phPeerEnum );
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupEnumConnections")]
+ public static IEnumerable PeerGroupEnumConnections(HGROUP hGroup, PEER_CONNECTION_FLAGS dwFlags) =>
+ PeerEnum(() => { PeerGroupEnumConnections(hGroup, dwFlags, out var h).ThrowIfFailed(); return h; });
+
+ ///
+ /// The PeerGroupEnumMembers function creates an enumeration of available peer group members and the associated membership information.
+ ///
+ ///
+ /// Handle to the peer group whose members are enumerated. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ ///
+ /// Specifies the PEER_MEMBER_FLAGS flags that indicate which types of members to include in the enumeration. If this value is set
+ /// to zero, all members of the peer group are included.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_MEMBER_PRESENT
+ /// Enumerate all members of the current peer group that are online.
+ ///
+ ///
+ ///
+ ///
+ /// Unicode string that contains the identity of a specific peer whose information is retrieved and returned in a one-item
+ /// enumeration. If this parameter is NULL, all members of the current peer group are retrieved. This parameter is required.
+ ///
+ ///
+ /// Pointer to the enumeration that contains the returned list of peer group members. This handle is passed to PeerGetNextItem to
+ /// retrieve the items, with each item represented as a pointer to a PEER_MEMBER structure. When finished, PeerEndEnumeration is
+ /// called to return the memory used by the enumeration. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ ///
+ /// The local node is always the very first item in the enumeration if pwzIdentity is NULL, and dwFlags is set to indicate
+ /// that the local node is a member of the explicit subset.
+ ///
+ ///
+ /// By default, every member publishes membership information to the peer group. If PEER_MEMBER_DATA_OPTIONAL is set on the
+ /// PEER_MEMBER data for that peer, this information is only available when a peer performs an action within the group, for example,
+ /// publishing a record, updating presence, or issuing a GMC.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupenummembers NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupEnumMembers( HGROUP hGroup, DWORD dwFlags, PCWSTR pwzIdentity, HPEERENUM *phPeerEnum );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupEnumMembers")]
+ public static extern HRESULT PeerGroupEnumMembers(HGROUP hGroup, PEER_MEMBER_FLAGS dwFlags, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, out SafeHPEERENUM phPeerEnum);
+
+ ///
+ /// The PeerGroupEnumMembers function creates an enumeration of available peer group members and the associated membership information.
+ ///
+ ///
+ /// Handle to the peer group whose members are enumerated. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ ///
+ /// Specifies the PEER_MEMBER_FLAGS flags that indicate which types of members to include in the enumeration. If this value is set
+ /// to zero, all members of the peer group are included.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_MEMBER_PRESENT
+ /// Enumerate all members of the current peer group that are online.
+ ///
+ ///
+ ///
+ ///
+ /// String that contains the identity of a specific peer whose information is retrieved and returned in a one-item enumeration. If
+ /// this parameter is , all members of the current peer group are retrieved.
+ ///
+ ///
+ /// The enumeration that contains the returned list of peer group members, with each item represented as a pointer to a PEER_MEMBER structure.
+ ///
+ ///
+ ///
+ /// The local node is always the very first item in the enumeration if pwzIdentity is , and dwFlags is set to
+ /// indicate that the local node is a member of the explicit subset.
+ ///
+ ///
+ /// By default, every member publishes membership information to the peer group. If PEER_MEMBER_DATA_OPTIONAL is set on the
+ /// PEER_MEMBER data for that peer, this information is only available when a peer performs an action within the group, for example,
+ /// publishing a record, updating presence, or issuing a GMC.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupenummembers NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupEnumMembers( HGROUP hGroup, DWORD dwFlags, PCWSTR pwzIdentity, HPEERENUM *phPeerEnum );
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupEnumMembers")]
+ public static IEnumerable PeerGroupEnumMembers(HGROUP hGroup, PEER_MEMBER_FLAGS dwFlags, [Optional] string pwzIdentity) =>
+ PeerEnum(() => { PeerGroupEnumMembers(hGroup, dwFlags, pwzIdentity, out var h).ThrowIfFailed(); return h; });
+
+ /// The PeerGroupEnumRecords function creates an enumeration of peer group records.
+ ///
+ /// Handle to the peer group whose records are enumerated. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to a GUID value that uniquely identifies a specific record type. If this parameter is NULL, all records
+ /// are returned.
+ ///
+ ///
+ /// Pointer to the enumeration that contains the returned list of records. This handle is passed to PeerGetNextItem to retrieve the
+ /// items, with each item represented as a pointer to a PEER_RECORD structure. When finished, PeerEndEnumeration is called to return
+ /// the memory used by the enumeration. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupenumrecords NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupEnumRecords( HGROUP hGroup, const GUID *pRecordType, HPEERENUM *phPeerEnum );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupEnumRecords")]
+ public static extern HRESULT PeerGroupEnumRecords(HGROUP hGroup, in Guid pRecordType, out SafeHPEERENUM phPeerEnum);
+
+ /// The PeerGroupEnumRecords function creates an enumeration of peer group records.
+ ///
+ /// Handle to the peer group whose records are enumerated. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to a GUID value that uniquely identifies a specific record type. If this parameter is NULL, all records
+ /// are returned.
+ ///
+ ///
+ /// The enumeration that contains the returned list of records, with each item represented as a pointer to a PEER_RECORD structure.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupenumrecords NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupEnumRecords( HGROUP hGroup, const GUID *pRecordType, HPEERENUM *phPeerEnum );
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupEnumRecords")]
+ public static IEnumerable PeerGroupEnumRecords(HGROUP hGroup, in Guid pRecordType) =>
+ PeerEnum(pRecordType, g => { PeerGroupEnumRecords(hGroup, g, out var h).ThrowIfFailed(); return h; });
+
+ ///
+ /// The PeerGroupExportConfig function exports the group configuration for a peer as an XML string that contains the
+ /// identity, group name, and the GMC for the identity.
+ ///
+ ///
+ /// Handle to the group. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Specifies the password used to protect the exported configuration. There are no rules or limits for the formation of this
+ /// password. This parameter is required.
+ ///
+ ///
+ /// Pointer to the returned XML configuration string that contains the identity, group peer name, cloud peer name, group scope, and
+ /// the GMC for the identity. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the identity or group keys is denied. Typically, this is caused by an incorrect access control list (ACL) for the
+ /// folder that contains the user or computer keys. This can happen when the ACL is reset manually .
+ ///
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft Base Cryptographic Provider. These errors are prefixed with
+ /// CRYPT_* and defined in Winerror.h.
+ ///
+ ///
+ ///
+ ///
+ /// After being exported, this configuration can be passed out-of-band to another peer, where the configuration of the identity can
+ /// be established. To import the configuration, pass the XML string returned by this function with the password set on it to PeerGroupImportConfig.
+ ///
+ /// The configuration XML string appears in the following format:
+ ///
+ /// <PEERGROUPCONFIG VERSION="1.0"> <IDENTITYPEERNAME> <!-- UTF-8 encoded peer name of the identity --> </IDENTITYPEERNAME> <GROUPPEERNAME> <!-- UTF-8 encoded peer name of the group --> </GROUPPEERNAME> <CLOUDNAME> <!-- UTF-8 encoded Unicode name of the cloud --> </CLOUDNAME> <SCOPE> <!-- UTF-8 encoded Unicode name of the scope: global, site-local, link-local --> </SCOPE> <CLOUDFLAGS> <!-- A DWORD containing cloud-specific settings, represented as a string --> </CLOUDFLAGS> <GMC xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64"> <!-- base64/PKCS7 encoded GMC chain --> </GMC> </PEERGROUPCONFIG>
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupexportconfig NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupExportConfig( HGROUP hGroup, PCWSTR pwzPassword, PWSTR *ppwzXML );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupExportConfig")]
+ public static extern HRESULT PeerGroupExportConfig(HGROUP hGroup, [MarshalAs(UnmanagedType.LPWStr)] string pwzPassword,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzXML);
+
+ ///
+ /// The PeerGroupExportDatabase function exports a peer group database to a specific file, which can be transported to
+ /// another computer and imported with the PeerGroupImportDatabase function.
+ ///
+ ///
+ /// Handle to the peer group whose database is exported to a local file on the peer. This handle is returned by the PeerGroupCreate,
+ /// PeerGroupOpen, or PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the absolute file system path and file name where the exported database is stored. For
+ /// example, "C:\backup\p2pdb.db". If this file already exists at the specified location, the older file is overwritten. This
+ /// parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ /// Note If an export fails due to a file system error, the appropriate file system error, defined in winerror.h, is returned.
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupexportdatabase NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupExportDatabase( HGROUP hGroup, PCWSTR pwzFilePath );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupExportDatabase")]
+ public static extern HRESULT PeerGroupExportDatabase(HGROUP hGroup, [MarshalAs(UnmanagedType.LPWStr)] string pwzFilePath);
+
+ /// The PeerGroupGetEventData function allows an application to retrieve the data returned by a grouping event.
+ /// Handle obtained from a previous call to PeerGroupRegisterEvent. This parameter is required.
+ ///
+ /// Pointer to a PEER_GROUP_EVENT_DATA structure that contains data about the peer event. This data structure must be freed after
+ /// use with PeerFreeData. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// PEER_S_NO_EVENT_DATA
+ /// The call is successful, but there is no event data available.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ ///
+ /// When an event occurs for which a peer has requested notification, the corresponding peer event handle is signaled. The peer
+ /// calls this method until PEER_GROUP_EVENT_DATA structures are retrieved. Each data structure contains the following two key
+ /// pieces of data:
+ ///
+ ///
+ /// -
+ /// The registration associated with a peer event.
+ ///
+ /// -
+ /// The actual data for a peer event.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupgeteventdata NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupGetEventData( HPEEREVENT hPeerEvent, PPEER_GROUP_EVENT_DATA *ppEventData );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupGetEventData")]
+ public static extern HRESULT PeerGroupGetEventData(HPEEREVENT hPeerEvent,
+ [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_GROUP_EVENT_DATA ppEventData);
+
+ /// The PeerGroupGetProperties function retrieves information on the properties of a specified group.
+ ///
+ /// Handle to a peer group whose properties are retrieved. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to a PEER_GROUP_PROPERTIES structure that contains information about peer group properties. This data must be freed with
+ /// PeerFreeData. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform a specified operation.
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The group is not in a state where peer group properties can be retrieved. For example, PeerGroupJoin is called, but
+ /// synchronization with the group database has not completed.
+ ///
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// Group properties cannot be retrieved if a peer has not synchronized with a peer group database. To synchronize with a peer group
+ /// database before calling this function, first call PeerGroupConnect.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupgetproperties NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupGetProperties( HGROUP hGroup, PPEER_GROUP_PROPERTIES *ppProperties );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupGetProperties")]
+ public static extern HRESULT PeerGroupGetProperties(HGROUP hGroup,
+ [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_GROUP_PROPERTIES ppProperties);
+
+ /// The PeerGroupGetRecord function retrieves a specific group record.
+ ///
+ /// Handle to a group that contains a specific record. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Specifies the GUID value that uniquely identifies a required record within a peer group. This parameter is required.
+ ///
+ ///
+ /// Pointer to the address of a PEER_RECORD structure that contains a returned record. This structure is freed by passing its
+ /// pointer to PeerFreeData. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The peer group is not in a state where group records can be retrieved. For example, PeerGroupJoin is called, but synchronization
+ /// with the peer group database has not completed.
+ ///
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to a peer group is invalid.
+ ///
+ /// -
+ /// PEER_E_RECORD_NOT_FOUND
+ /// A record that matches the supplied ID cannot be found in a peer group database.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupgetrecord NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupGetRecord( HGROUP hGroup, const GUID *pRecordId, PPEER_RECORD *ppRecord );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupGetRecord")]
+ public static extern HRESULT PeerGroupGetRecord(HGROUP hGroup, in Guid pRecordId,
+ [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_RECORD ppRecord);
+
+ /// The PeerGroupGetStatus function retrieves the current status of a group.
+ ///
+ /// Handle to a peer group whose status is returned. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or PeerGroupJoin
+ /// function. This parameter is required.
+ ///
+ /// Pointer to a set of PEER_GROUP_STATUS flags that describe the status of a peer group.
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One or more of the parameters is invalid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete an operation.
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to a group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupgetstatus NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupGetStatus( HGROUP hGroup, DWORD *pdwStatus );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupGetStatus")]
+ public static extern HRESULT PeerGroupGetStatus(HGROUP hGroup, out PEER_GROUP_STATUS pdwStatus);
+
+ ///
+ /// The PeerGroupImportConfig function imports a peer group configuration for an identity based on the specific settings in a
+ /// supplied XML configuration string.
+ ///
+ ///
+ /// Specifies a Unicode string that contains a previously exported (using PeerGroupExportConfig) peer group configuration. For the
+ /// specific XML format of the string, see to the Remarks section of this topic. This parameter is required.
+ ///
+ ///
+ /// Specifies the password used to access the encrypted peer group configuration data, as a Unicode string. This parameter is required.
+ ///
+ ///
+ /// If true, the existing group configuration is overwritten. If false, the group configuration is written only if a previous group
+ /// configuration does not exist. The default value is false. This parameter is required.
+ ///
+ /// Contains the peer identity returned after an import completes. This parameter is required.
+ /// Contains a peer group peer name returned after an import completes. This parameter is required.
+ ///
+ /// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform a specified operation.
+ ///
+ /// -
+ /// PEER_E_ALREADY_EXISTS
+ /// A peer group configuration already exists, and fOverwrite is set to false.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ ///
+ /// To generate a peer group configuration, call PeerGroupExportConfig, pass in an identity to export, a password, and a handle to
+ /// the peer group.
+ ///
+ /// The configuration XML string appears in the following format:
+ ///
+ /// <PEERGROUPCONFIG VERSION="1.0"> <IDENTITYPEERNAME> <!-- UTF-8 encoded peer name of the identity --> </IDENTITYPEERNAME> <GROUPPEERNAME> <!-- UTF-8 encoded peer name of the peer group --> </GROUPPEERNAME> <CLOUDNAME> <!-- UTF-8 encoded Unicode name of the cloud --> </CLOUDNAME> <SCOPE> <!-- UTF-8 encoded Unicode name of the scope: global, site-local, link-local --> </SCOPE> <CLOUDFLAGS> <!-- A DWORD that contains cloud-specific settings, represented as a string --> </CLOUDFLAGS> <GMC xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64"> <!-- base64/PKCS7 encoded GMC chain --> </GMC> </PEERGROUPCONFIG>
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupimportconfig NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupImportConfig( PCWSTR pwzXML, PCWSTR pwzPassword, BOOL fOverwrite, PWSTR *ppwzIdentity, PWSTR *ppwzGroup );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupImportConfig")]
+ public static extern HRESULT PeerGroupImportConfig([MarshalAs(UnmanagedType.LPWStr)] string pwzXML, [MarshalAs(UnmanagedType.LPWStr)] string pwzPassword,
+ [MarshalAs(UnmanagedType.Bool)] bool fOverwrite,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzIdentity,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzGroup);
+
+ /// The PeerGroupImportDatabase function imports a peer group database from a local file.
+ ///
+ /// Handle to a peer group whose database is imported from a local file. This handle is returned by the PeerGroupCreate,
+ /// PeerGroupOpen, or PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the absolute file system path and file name where the data is stored, for example,
+ /// "C:\backup\p2pdb.db". If the file does not exist at this location, an appropriate error from the file system is returned. This
+ /// parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ /// Note If an import fails due to a file system error, the appropriate file system error is returned.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// PEER_E_GROUP_IN_USE
+ ///
+ /// The operation cannot be completed because the peer group database is currently in use. For example, PeerGroupConnect has been
+ /// called by a peer, but has not yet completed any database transactions.
+ ///
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ /// This function must be called before PeerGroupConnect, and after PeerGroupOpen or PeerGroupJoin.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupimportdatabase NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupImportDatabase( HGROUP hGroup, PCWSTR pwzFilePath );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupImportDatabase")]
+ public static extern HRESULT PeerGroupImportDatabase(HGROUP hGroup, [MarshalAs(UnmanagedType.LPWStr)] string pwzFilePath);
+
+ ///
+ /// The PeerGroupIssueCredentials function issues credentials, including a GMC, to a specific identity, and optionally
+ /// returns an invitation XML string the invited peer can use to join a peer group.
+ ///
+ ///
+ /// Handle to a peer group for which a peer will issue credentials to potential invited peers. This handle is returned by the
+ /// PeerGroupCreate, PeerGroupOpen, or PeerGroupJoin function. This parameter is required.
+ ///
+ /// Specifies the identity of a peer to whom credentials will be issued. This parameter is required.
+ ///
+ ///
+ /// PEER_CREDENTIAL_INFO structure that contains information about the credentials of a peer whose identity is specified in
+ /// pwzSubjectIdentity. If this parameter is NULL, the information stored in the peer database is used, instead. This
+ /// parameter is optional.
+ ///
+ /// If this parameter is provided, the following fields in
+ /// PEER_CREDENTIAL_INFO
+ /// are ignored:
+ ///
+ /// -
+ /// pwzIssuerPeerName
+ ///
+ /// -
+ /// pwzIssuerFriendlyName
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Specifies a set of flags used to describe actions taken when credentials are issued. If this parameter is set to 0 (zero), the
+ /// credentials are returned in ppwzInvitation. This parameter is optional.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_GROUP_STORE_CREDENTIALS
+ ///
+ /// Publish the subject identity's newly-created GMC in the group database. The GMC is picked up automatically by the subject. If
+ /// this flag is not set, the credentials must be obtained by a different application such as email.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to an invitation XML string returned by the function call. This invitation is passed out-of-band to the invited peer who
+ /// uses it in a call to PeerGroupJoin. This parameter is optional.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete the operation.
+ ///
+ /// -
+ /// PEER_E_IDENTITY_DELETED
+ /// The identity creating the credentials has been deleted.
+ ///
+ /// -
+ /// PEER_E_IDENTITY_NOT_FOUND
+ /// The identity cannot be found in the group database, and pCredentialInfo is NULL.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the identity or group keys is denied. Typically, this is caused by an incorrect access control list (ACL) for the
+ /// folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
+ ///
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// This function can only be called successfully by an administrator.
+ ///
+ /// The credentials for a member (PEER_CREDENTIAL_INFO) are obtained by calling PeerGroupEnumMembers. The credentials are located in
+ /// the pCredentialInfo field of the PEER_MEMBER structure for a specific member.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupissuecredentials NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupIssueCredentials( HGROUP hGroup, PCWSTR pwzSubjectIdentity, PEER_CREDENTIAL_INFO *pCredentialInfo, DWORD dwFlags, PWSTR
+ // *ppwzInvitation );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupIssueCredentials")]
+ public static extern HRESULT PeerGroupIssueCredentials(HGROUP hGroup, [MarshalAs(UnmanagedType.LPWStr)] string pwzSubjectIdentity,
+ in PEER_CREDENTIAL_INFO pCredentialInfo, PEER_GROUP_ISSUE_CREDENTIAL_FLAGS dwFlags,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzInvitation);
+
+ ///
+ /// The PeerGroupIssueCredentials function issues credentials, including a GMC, to a specific identity, and optionally
+ /// returns an invitation XML string the invited peer can use to join a peer group.
+ ///
+ ///
+ /// Handle to a peer group for which a peer will issue credentials to potential invited peers. This handle is returned by the
+ /// PeerGroupCreate, PeerGroupOpen, or PeerGroupJoin function. This parameter is required.
+ ///
+ /// Specifies the identity of a peer to whom credentials will be issued. This parameter is required.
+ ///
+ ///
+ /// PEER_CREDENTIAL_INFO structure that contains information about the credentials of a peer whose identity is specified in
+ /// pwzSubjectIdentity. If this parameter is NULL, the information stored in the peer database is used, instead. This
+ /// parameter is optional.
+ ///
+ /// If this parameter is provided, the following fields in
+ /// PEER_CREDENTIAL_INFO
+ /// are ignored:
+ ///
+ /// -
+ /// pwzIssuerPeerName
+ ///
+ /// -
+ /// pwzIssuerFriendlyName
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Specifies a set of flags used to describe actions taken when credentials are issued. If this parameter is set to 0 (zero), the
+ /// credentials are returned in ppwzInvitation. This parameter is optional.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_GROUP_STORE_CREDENTIALS
+ ///
+ /// Publish the subject identity's newly-created GMC in the group database. The GMC is picked up automatically by the subject. If
+ /// this flag is not set, the credentials must be obtained by a different application such as email.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to an invitation XML string returned by the function call. This invitation is passed out-of-band to the invited peer who
+ /// uses it in a call to PeerGroupJoin. This parameter is optional.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete the operation.
+ ///
+ /// -
+ /// PEER_E_IDENTITY_DELETED
+ /// The identity creating the credentials has been deleted.
+ ///
+ /// -
+ /// PEER_E_IDENTITY_NOT_FOUND
+ /// The identity cannot be found in the group database, and pCredentialInfo is NULL.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the identity or group keys is denied. Typically, this is caused by an incorrect access control list (ACL) for the
+ /// folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
+ ///
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// This function can only be called successfully by an administrator.
+ ///
+ /// The credentials for a member (PEER_CREDENTIAL_INFO) are obtained by calling PeerGroupEnumMembers. The credentials are located in
+ /// the pCredentialInfo field of the PEER_MEMBER structure for a specific member.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupissuecredentials NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupIssueCredentials( HGROUP hGroup, PCWSTR pwzSubjectIdentity, PEER_CREDENTIAL_INFO *pCredentialInfo, DWORD dwFlags, PWSTR
+ // *ppwzInvitation );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupIssueCredentials")]
+ public static extern HRESULT PeerGroupIssueCredentials(HGROUP hGroup, [MarshalAs(UnmanagedType.LPWStr)] string pwzSubjectIdentity,
+ [In, Optional] IntPtr pCredentialInfo, PEER_GROUP_ISSUE_CREDENTIAL_FLAGS dwFlags, [In, Optional] IntPtr ppwzInvitation);
+
+ ///
+ /// The PeerGroupJoin function prepares a peer with an invitation to join an existing peer group prior to calling
+ /// PeerGroupConnect or PeerGroupConnectByAddress.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the identity opening the specified peer group. If this parameter is NULL, the
+ /// implementation uses the identity obtained from PeerIdentityGetDefault.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the XML invitation granted by another peer. An invitation is created when the inviting
+ /// peer calls PeerGroupCreateInvitation or PeerGroupIssueCredentials. Specific details regarding this invitation can be obtained as
+ /// a PEER_INVITATION_INFO structure by calling PeerGroupParseInvitation. This parameter is required.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the name of the PNRP cloud where a group is located. The default value is NULL,
+ /// which indicates that the cloud specified in the invitation must be used.
+ ///
+ ///
+ /// Pointer to the handle of the peer group. To start communication with a group, call PeerGroupConnect. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete the operation.
+ ///
+ /// -
+ /// PEER_E_CLOUD_NAME_AMBIGUOUS
+ /// The cloud cannot be uniquely discovered, for example, more than one cloud matches the provided name.
+ ///
+ /// -
+ /// PEER_E_INVALID_PEER_NAME
+ /// The peer identity specified in pwzIdentity is invalid.
+ ///
+ /// -
+ /// PEER_E_INVALID_TIME_PERIOD
+ ///
+ /// The validity period specified in the invitation is invalid. Either the specified period has expired or the invitation is not yet
+ /// valid (i.e. the specified ValidityStart date\time has not yet been reached). One possible reason for the return of this error is
+ /// that the system clock is incorrectly set on the machine joining the group, or on the machine that issued the invitation.
+ ///
+ ///
+ /// -
+ /// PEER_E_INVITATION_NOT_TRUSTED
+ /// The invitation is not trusted. This may be due to invitation alteration, errors, or expiration.
+ ///
+ /// -
+ /// PEER_E_NO_CLOUD
+ /// The cloud cannot be located.
+ ///
+ /// -
+ /// PEER_E_UNSUPPORTED_VERSION
+ /// The invitation is not supported by the current version of the Peer Infrastructure.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the peer identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL)
+ /// for the folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
+ ///
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupjoin NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerGroupJoin(
+ // PCWSTR pwzIdentity, PCWSTR pwzInvitation, PCWSTR pwzCloud, HGROUP *phGroup );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupJoin")]
+ public static extern HRESULT PeerGroupJoin([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, [MarshalAs(UnmanagedType.LPWStr)] string pwzInvitation,
+ [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwzCloud, out HGROUP phGroup);
+
+ ///
+ /// The PeerGroupOpen function opens a peer group that a peer has created or joined. After a peer group is opened, the peer
+ /// can register for event notifications.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the identity a peer uses to open a group. This parameter is required.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the peer name of the peer group. This parameter is required.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the name of the PNRP cloud in which the peer group is located. If the value is
+ /// NULL, the cloud specified in the peer group properties is used.
+ ///
+ ///
+ /// Pointer to a handle for a peer group. If this value is NULL, the open operation is unsuccessful. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete the operation.
+ ///
+ /// -
+ /// PEER_E_CLOUD_NAME_AMBIGUOUS
+ /// The cloud specified in pwzCloud cannot be uniquely discovered, for example, more than one cloud matches the provided name.
+ ///
+ /// -
+ /// PEER_E_NO_CLOUD
+ /// The cloud specified in pwzCloud cannot be located.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the peer identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL)
+ /// for the folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
+ ///
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// Multiple applications can open the same group simultaneously. Any application can choose to open a group without subsequently
+ /// calling PeerGroupConnect. These applications are considered to be offline. However, a second application can open and connect
+ /// the peer to the group, which means that an application must be ready to connect at any time.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupopen NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerGroupOpen(
+ // PCWSTR pwzIdentity, PCWSTR pwzGroupPeerName, PCWSTR pwzCloud, HGROUP *phGroup );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupOpen")]
+ public static extern HRESULT PeerGroupOpen([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, [MarshalAs(UnmanagedType.LPWStr)] string pwzGroupPeerName,
+ [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwzCloud, out HGROUP phGroup);
+
+ /// The PeerGroupOpenDirectConnection function establishes a direct connection with another peer in a peer group.
+ ///
+ /// Handle to the peer group that hosts the direct connection. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ /// Pointer to a Unicode string that contains the identity a peer connects to. This parameter is required.
+ ///
+ /// Pointer to a PEER_ADDRESS structure that contains the IPv6 address the peer connects to. This parameter is required.
+ ///
+ ///
+ /// Unsigned 64-bit integer that identifies the direct connection. This ID value cannot be assumed as valid until the
+ /// PEER_GROUP_EVENT_DIRECT_CONNECTION event is raised and indicates that the connection has been accepted by the other peer. This
+ /// parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete the operation.
+ ///
+ /// -
+ /// PEER_E_CONNECT_SELF
+ /// The connection failed because it was a loopback, that is, the connection is between a peer and itself.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the peer identity or peer group keys is denied. This is typically caused by an incorrect access control list (ACL) for
+ /// the folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
+ ///
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// Every direct connection opened with this function must be closed with PEER_GROUP_EVENT DATA structure has the status
+ /// member of its component PEER_EVENT_CONNECTION_CHANGE_DATA structure set to PEER_CONNECTION_FAILED.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupopendirectconnection NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupOpenDirectConnection( HGROUP hGroup, PCWSTR pwzIdentity, PPEER_ADDRESS pAddress, ULONGLONG *pullConnectionId );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupOpenDirectConnection")]
+ public static extern HRESULT PeerGroupOpenDirectConnection(HGROUP hGroup, [MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, in PEER_ADDRESS pAddress, out ulong pullConnectionId);
+
+ ///
+ /// The PeerGroupParseInvitation function returns a PEER_INVITATION_INFO structure with the details of a specific invitation.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the specific peer group invitation. This parameter is required.
+ ///
+ ///
+ /// Pointer to a PEER_INVITATION_INFO structure with the details of a specific invitation. To release the resources used by this
+ /// structure, pass this pointer to PeerFreeData. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete an operation.
+ ///
+ /// -
+ /// PEER_E_INVITATION_NOT_TRUSTED
+ /// The invitation is not trusted by the peer. It has been altered or contains errors.
+ ///
+ /// -
+ /// PEER_E_UNSUPPORTED_VERSION
+ /// The invitation is not supported by the current version of the Peer Infrastructure.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupparseinvitation NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupParseInvitation( PCWSTR pwzInvitation, PPEER_INVITATION_INFO *ppInvitationInfo );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupParseInvitation")]
+ public static extern HRESULT PeerGroupParseInvitation([MarshalAs(UnmanagedType.LPWStr)] string pwzInvitation,
+ [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_INFO ppInvitationInfo);
+
+ ///
+ /// The PeerGroupPasswordJoin function prepares a peer with an invitation and the correct password to join a
+ /// password-protected peer group prior to calling PeerGroupConnect or PeerGroupConnectByAddress.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the identity opening the specified peer group. If this parameter is NULL, the
+ /// implementation uses the identity obtained from PeerIdentityGetDefault.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the XML invitation granted by another peer. An invitation with a password is created
+ /// when the inviting peer calls PeerGroupCreatePasswordInvitation. Specific details regarding this invitation, including the
+ /// password set by the group creator, can be obtained as a PEER_INVITATION_INFO structure by calling PeerGroupParseInvitation. This
+ /// parameter is required.
+ ///
+ ///
+ /// Pointer to a zero-terminated Unicode string that contains the password required to validate and join the peer group. This
+ /// password must match the password specified in the invitation. This parameter is required.
+ ///
+ ///
+ /// Pointer to a Unicode string that contains the name of the PNRP cloud where a group is located. The default value is NULL,
+ /// which indicates that the cloud specified in the invitation must be used.
+ ///
+ ///
+ /// Pointer to the handle of the peer group. To start communication with a group, call PeerGroupConnect. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete the operation.
+ ///
+ /// -
+ /// PEER_E_CLOUD_NAME_AMBIGUOUS
+ /// The cloud cannot be uniquely discovered, for example, more than one cloud matches the provided name.
+ ///
+ /// -
+ /// PEER_E_INVALID_PEER_NAME
+ /// The peer identity specified in pwzIdentity is invalid.
+ ///
+ /// -
+ /// PEER_E_INVITATION_NOT_TRUSTED
+ /// The invitation is not trusted by the peer. It has been altered or contains errors.
+ ///
+ /// -
+ /// PEER_E_NO_CLOUD
+ /// The cloud cannot be located.
+ ///
+ /// -
+ /// PEER_E_UNSUPPORTED_VERSION
+ /// The invitation is not supported by the current version of the Peer Infrastructure.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the peer identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL)
+ /// for the folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
+ ///
+ ///
+ /// -
+ /// PEER_S_ALREADY_A_MEMBER
+ /// The local peer attempted to join a group based on a password more than once.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors may be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// In the event of a clock skew between participating machines, the initial PeerGroupPasswordJoin function may still succeed
+ /// while the following call of PeerGroupConnect can result in a failure to join depending on the severity of the skew.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergrouppasswordjoin NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupPasswordJoin( PCWSTR pwzIdentity, PCWSTR pwzInvitation, PCWSTR pwzPassword, PCWSTR pwzCloud, HGROUP *phGroup );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupPasswordJoin")]
+ public static extern HRESULT PeerGroupPasswordJoin([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, [MarshalAs(UnmanagedType.LPWStr)] string pwzInvitation,
+ [MarshalAs(UnmanagedType.LPWStr)] string pwzPassword, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwzCloud, out HGROUP phGroup);
+
+ ///
+ /// The PeerGroupPeerTimeToUniversalTime function converts the peer group-maintained reference time value to a localized time
+ /// value appropriate for display on a peer computer.
+ ///
+ ///
+ /// Handle to the peer group that a peer participates in. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to the peer time value—Coordinated Universal Time (UTC)—that is represented as a FILETIME structure. This parameter is required.
+ ///
+ ///
+ /// Pointer to the returned universal time value that is represented as a FILETIME structure. This parameter is NULL if an
+ /// error occurs.
+ ///
+ ///
+ ///
+ /// Returns S_OK if the function succeeds. Otherwise, the function returns either one of the remote procedure call (RPC)
+ /// errors or one of the following errors.
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The peer group is not in a state that peer time can be retrieved accurately, for example, PeerGroupJoin has been called, but
+ /// synchronization with the group database has not completed.
+ ///
+ ///
+ /// -
+ /// PEER_E_NOT_INITIALIZED
+ /// The peer group must be initialized with a call to PeerGroupStartup before using this function.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// Universal time is the universal time value maintained on a peer computer.
+ ///
+ /// Peer time is a common reference time maintained by a peer group, expressed as UTC. It is often offset from the universal time
+ /// value, and is used to correct latency issues.
+ ///
+ /// Universal time can be converted to peer time by calling the converse function PeerGroupUniversalTimeToPeerTime.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergrouppeertimetouniversaltime NOT_BUILD_WINDOWS_DEPRECATE
+ // HRESULT PeerGroupPeerTimeToUniversalTime( HGROUP hGroup, FILETIME *pftPeerTime, FILETIME *pftUniversalTime );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupPeerTimeToUniversalTime")]
+ public static extern HRESULT PeerGroupPeerTimeToUniversalTime(HGROUP hGroup, in FILETIME pftPeerTime, out FILETIME pftUniversalTime);
+
+ /// The PeerGroupRegisterEvent function registers a peer for specific peer group events.
+ ///
+ /// Handle of the peer group on which to monitor the specific peer events. This handle is returned by the PeerGroupCreate,
+ /// PeerGroupOpen, or PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to a Windows event handle, which is signaled when a peer event is fired. When this handle is signaled, the peer should
+ /// call PeerGroupGetEventData until the function returns PEER_S_NO_EVENT_DATA. This parameter is required.
+ ///
+ ///
+ /// Contains the number of PEER_GROUP_EVENT_REGISTRATION structures listed in pEventRegistrations. This parameter is required.
+ ///
+ ///
+ /// Pointer to a list of PEER_GROUP_EVENT_REGISTRATION structures that contains the peer event types for which registration occurs.
+ /// This parameter is required.
+ ///
+ ///
+ /// Pointer to the returned HPEEREVENT handle. A peer can unregister for this peer event by passing this handle to
+ /// PeerGroupUnregisterEvent. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete the operation.
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the group is invalid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ /// Before you close the HPEEREVENT handle, you must unregister for the peer event types by passing the handle to PeerGroupUnregisterEvent.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupregisterevent NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupRegisterEvent( HGROUP hGroup, HANDLE hEvent, DWORD cEventRegistration, PEER_GROUP_EVENT_REGISTRATION
+ // *pEventRegistrations, HPEEREVENT *phPeerEvent );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupRegisterEvent")]
+ public static extern HRESULT PeerGroupRegisterEvent(HGROUP hGroup, HANDLE hEvent, uint cEventRegistration,
+ [In, MarshalAs(UnmanagedType.LPArray)] PEER_GROUP_EVENT_REGISTRATION[] pEventRegistrations, out SafeHPEEREVENT phPeerEvent);
+
+ ///
+ /// The PeerGroupSearchRecords function searches the local peer group database for records that match the supplied criteria.
+ ///
+ ///
+ /// Handle to the peer group whose local database is searched. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to a Unicode XML string that contains the record search query. For information about formulating an XML query string to
+ /// search the peer group records database, see the Record Search Query Format documentation. This parameter is required.
+ ///
+ ///
+ /// Pointer to the enumeration that contains the returned list of records. This handle is passed to PeerGetNextItem to retrieve the
+ /// items with each item represented as a pointer to a PEER_RECORD structure. When finished, PeerEndEnumeration is called to return
+ /// the memory used by the enumeration. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete the operation.
+ ///
+ /// -
+ /// PEER_E_INVALID_SEARCH
+ /// The XML search query does not adhere to the search query schema specification.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupsearchrecords NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupSearchRecords( HGROUP hGroup, PCWSTR pwzCriteria, HPEERENUM *phPeerEnum );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupSearchRecords")]
+ public static extern HRESULT PeerGroupSearchRecords(HGROUP hGroup, [MarshalAs(UnmanagedType.LPWStr)] string pwzCriteria, out SafeHPEERENUM phPeerEnum);
+
+ ///
+ /// The PeerGroupSearchRecords function searches the local peer group database for records that match the supplied criteria.
+ ///
+ ///
+ /// Handle to the peer group whose local database is searched. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to an XML string that contains the record search query. For information about formulating an XML query string to search
+ /// the peer group records database, see the Record Search Query Format documentation. This parameter is required.
+ ///
+ ///
+ /// The enumeration that contains the returned list of records, with each item represented as a pointer to a PEER_RECORD structure.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupsearchrecords NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupSearchRecords( HGROUP hGroup, PCWSTR pwzCriteria, HPEERENUM *phPeerEnum );
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupSearchRecords")]
+ public static IEnumerable PeerGroupSearchRecords(HGROUP hGroup, string pwzCriteria) =>
+ PeerEnum(() => { PeerGroupSearchRecords(hGroup, pwzCriteria, out var h).ThrowIfFailed(); return h; });
+
+ /// The PeerGroupSendData function sends data to a member over a neighbor or direct connection.
+ ///
+ /// Handle to the group that contains both members of a connection. This handle is returned by the PeerGroupCreate, PeerGroupOpen,
+ /// or PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Unsigned 64-bit integer that contains the ID of the connection that hosts the data transmission. A connection ID is obtained by
+ /// calling PeerGroupOpenDirectConnection. This parameter is required.
+ ///
+ /// Pointer to a GUID value that uniquely identifies the data being transmitted. This parameter is required.
+ /// Specifies the size of the data in pvData, in bytes. This parameter is required.
+ ///
+ /// Pointer to the block of data to send. The receiving application is responsible for parsing this data. This parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// PEER_E_CONNECTION_NOT_FOUND
+ /// A connection with the ID specified in ullConnectionId cannot be found.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ /// To receive data, the receiving peer must have registered for the PEER_GROUP_EVENT_INCOMING_DATA peer event.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupsenddata NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupSendData( HGROUP hGroup, ULONGLONG ullConnectionId, const GUID *pType, ULONG cbData, PVOID pvData );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupSendData")]
+ public static extern HRESULT PeerGroupSendData(HGROUP hGroup, ulong ullConnectionId, in Guid pType, uint cbData, [In] IntPtr pvData);
+
+ ///
+ /// The PeerGroupSetProperties function sets the current peer group properties. In version 1.0 of this API, only the creator
+ /// of the peer group can perform this operation.
+ ///
+ ///
+ /// Handle to the peer group whose properties are set by a peer. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ ///
+ /// Pointer to a peer-populated PEER_GROUP_PROPERTIES structure that contains the new properties. To obtain this structure, a peer
+ /// must first call PeerGroupGetProperties, change the appropriate fields, and then pass it as this parameter. This parameter is required.
+ ///
+ /// The following members of
+ /// PEER_GROUP_PROPERTIES
+ /// cannot be changed:
+ ///
+ /// -
+ /// dwSize
+ ///
+ /// -
+ /// pwzCloud
+ ///
+ /// -
+ /// pwzClassifier
+ ///
+ /// -
+ /// pwzGroupPeerName
+ ///
+ /// -
+ /// pwzCreatorPeerName
+ ///
+ ///
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete the operation.
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The group is not in a state where peer group properties can be set. For example, PeerGroupJoin has been called, but
+ /// synchronization with the peer group database is not complete.
+ ///
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP_PROPERTIES
+ /// One or more of the specified properties is invalid.
+ ///
+ /// -
+ /// PEER_E_NOT_AUTHORIZED
+ ///
+ /// The current identity does not have the authorization to change these properties. In this case, the identity is not the creator
+ /// of the peer group.
+ ///
+ ///
+ /// -
+ /// PEER_E_PASSWORD_DOES_NOT_MEET_POLICY
+ /// Password specified does not meet system password requirements.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// For applications that utilize passwords, it is recommended the passwords are handled securely by calling the CryptoProtectMemory
+ /// and SecureZeroMemory functions.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupsetproperties NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupSetProperties( HGROUP hGroup, PPEER_GROUP_PROPERTIES pProperties );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupSetProperties")]
+ public static extern HRESULT PeerGroupSetProperties(HGROUP hGroup, in PEER_GROUP_PROPERTIES pProperties);
+
+ ///
+ /// The PeerGroupShutdown function closes a peer group created with PeerGroupStartup and disposes of any allocated resources.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns the following value.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_UNEXPECTED
+ /// The function terminated unexpectedly.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupshutdown NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerGroupShutdown();
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupShutdown")]
+ public static extern HRESULT PeerGroupShutdown();
+
+ /// The PeerGroupStartup function initiates a peer group by using a requested version of the Peer infrastructure.
+ ///
+ /// Specifies the highest version of the Peer Infrastructure that a caller can support. The high order byte specifies the minor
+ /// version (revision) number. The low order byte specifies the major version number This parameter is required.
+ ///
+ ///
+ /// Pointer to a PEER_VERSION_DATA structure that contains the specific level of support provided by the Peer Infrastructure. This
+ /// parameter is required.
+ ///
+ ///
+ /// Returns S_OK if the function succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_SERVICE_DEPENDENCY_FAIL
+ /// The Peer Name Resolution Protocol (PNRP) service must be started before calling PeerGroupStartup.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory available to complete the operation.
+ ///
+ /// -
+ /// PEER_E_IPV6_NOT_INSTALLED
+ /// The grouping service failed to start because IPv6 is not installed on the computer.
+ ///
+ /// -
+ /// PEER_E_UNSUPPORTED_VERSION
+ /// The requested version is not supported by the installed Peer subsystem.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// The Peer Name Resolution Protocol (PNRP) service must be started before calling this function.
+ /// This function is called by the application before calling any other Peer Grouping function.
+ /// For this release, applications should use PEER_GROUP_VERSION as the requested version.
+ /// A peer group started with this function is closed by calling PeerGroupShutdown when the application terminates.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupstartup NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupStartup( WORD wVersionRequested, PPEER_VERSION_DATA pVersionData );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupStartup")]
+ public static extern HRESULT PeerGroupStartup(ushort wVersionRequested, out PEER_VERSION_DATA pVersionData);
+
+ ///
+ /// The PeerGroupUniversalTimeToPeerTime function converts a local time value from a peer's computer to a common peer group
+ /// time value.
+ ///
+ ///
+ /// Handle to the peer group a peer participates in. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or PeerGroupJoin
+ /// function. This parameter is required.
+ ///
+ ///
+ /// Pointer to the universal time value, represented as a FILETIME structure. This parameter is required.
+ ///
+ ///
+ /// Pointer to the returned peer time—Greenwich Mean Time (GMT) value that is represented as a FILETIME structure. This parameter is
+ /// NULL if an error occurs.
+ ///
+ ///
+ ///
+ /// Returns S_OK if the function succeeds. Otherwise, the function returns either one of the RPC errors or one of the
+ /// following values.
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The peer group is not in a state where peer time can be accurately calculated. For example, PeerGroupJoin has been called, but
+ /// synchronization with the peer group database has not completed.
+ ///
+ ///
+ /// -
+ /// PEER_E_NOT_INITIALIZED
+ /// The group must be initialized with a call to PeerGroupStartup before using this function.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ ///
+ /// Universal time is the universal time value maintained on a peer's computer.
+ ///
+ /// Peer time is a common reference time maintained by a peer group, expressed as Coordinated Universal Time (UTC). It is often
+ /// offset from the universal time value, and is used to correct latency issues.
+ ///
+ /// Peer time can be converted to universal time by calling the converse function PeerGroupPeerTimeToUniversalTime.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupuniversaltimetopeertime NOT_BUILD_WINDOWS_DEPRECATE
+ // HRESULT PeerGroupUniversalTimeToPeerTime( HGROUP hGroup, FILETIME *pftUniversalTime, FILETIME *pftPeerTime );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupUniversalTimeToPeerTime")]
+ public static extern HRESULT PeerGroupUniversalTimeToPeerTime(HGROUP hGroup, in FILETIME pftUniversalTime, out FILETIME pftPeerTime);
+
+ ///
+ /// The PeerGroupUnregisterEvent function unregisters a peer from notification of peer events associated with the supplied
+ /// event handle.
+ ///
+ /// Handle returned by a previous call to PeerGroupRegisterEvent. This parameter is required.
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns the following value.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// The parameter is not valid.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ /// This function must be called before the HPEEREVENT handle is closed.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupunregisterevent NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupUnregisterEvent( HPEEREVENT hPeerEvent );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupUnregisterEvent")]
+ public static extern HRESULT PeerGroupUnregisterEvent(HPEEREVENT hPeerEvent);
+
+ /// The PeerGroupUpdateRecord function updates a record within a specific peer group.
+ ///
+ /// Handle to the peer group whose record is updated. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or
+ /// PeerGroupJoin function. This parameter is required.
+ ///
+ ///
+ /// Pointer to a PEER_RECORD structure that contains the updated record for hGroup. This parameter is required.
+ /// The following members in PEER_RECORD can be updated.
+ ///
+ /// -
+ /// pwzAttributes
+ ///
+ /// -
+ /// ftExpiration
+ ///
+ /// -
+ /// data
+ ///
+ ///
+ /// The following members in
+ /// PEER_RECORD
+ /// must be present, but cannot be changed.
+ ///
+ /// -
+ /// dwSize
+ ///
+ /// -
+ /// id
+ ///
+ /// -
+ /// type
+ ///
+ /// -
+ /// dwFlags
+ ///
+ ///
+ /// The following members are ignored if populated.
+ ///
+ /// -
+ /// dwVersion
+ ///
+ /// -
+ /// pwzCreatorId
+ ///
+ /// -
+ /// pwzModifiedById
+ ///
+ /// -
+ /// ftCreation
+ ///
+ /// -
+ /// ftLastModified
+ ///
+ /// -
+ /// securityData
+ ///
+ ///
+ /// The members that remain are optional.
+ ///
+ ///
+ /// Returns S_OK if the operation succeeds. Otherwise, the function returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the specified parameters is invalid.
+ ///
+ /// -
+ /// PEER_E_GROUP_NOT_READY
+ ///
+ /// The peer group is not in a state where a record can be updated, for example, PeerGroupJoin has been called, but synchronization
+ /// with the peer group database is not complete.
+ ///
+ ///
+ /// -
+ /// PEER_E_INVALID_GROUP
+ /// The handle to the peer group is invalid.
+ ///
+ /// -
+ /// PEER_E_NOT_AUTHORIZED
+ ///
+ /// The current peer identity does not have the authorization to delete the record. In this case, the peer identity is not the
+ /// creator of the record.
+ ///
+ ///
+ /// -
+ /// PEER_E_RECORD_NOT_FOUND
+ /// The record cannot be located in the data store.
+ ///
+ ///
+ ///
+ /// Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and
+ /// defined in Winerror.h.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peergroupupdaterecord NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerGroupUpdateRecord( HGROUP hGroup, PPEER_RECORD pRecord );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerGroupUpdateRecord")]
+ public static extern HRESULT PeerGroupUpdateRecord(HGROUP hGroup, in PEER_RECORD pRecord);
+
+ /// Provides a handle to a peer group.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HGROUP : IHandle
+ {
+ private IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HGROUP(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HGROUP NULL => new HGROUP(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(HGROUP h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HGROUP(IntPtr h) => new HGROUP(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HGROUP h1, HGROUP h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HGROUP h1, HGROUP h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HGROUP h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/P2P/P2P.Identity.cs b/PInvoke/P2P/P2P.Identity.cs
new file mode 100644
index 00000000..2f5fab6b
--- /dev/null
+++ b/PInvoke/P2P/P2P.Identity.cs
@@ -0,0 +1,616 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using Vanara.Extensions;
+using Vanara.InteropServices;
+using static Vanara.PInvoke.AdvApi32;
+using static Vanara.PInvoke.Crypt32;
+using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the P2P.dll
+ public static partial class P2P
+ {
+ ///
+ /// The PeerCreatePeerName function creates a new name based on the existing name of the specified peer identity and
+ /// classifier. However, a new identity is not created by a call to PeerCreatePeerName.
+ ///
+ ///
+ ///
+ /// Specifies the identity to use as the basis for the new peer name. If pwzIdentity is NULL, the name created is not based
+ /// on any peer identity, and is therefore an unsecured name.
+ ///
+ /// This parameter can only be NULL if pwzClassifier is not NULL.
+ ///
+ ///
+ ///
+ /// Pointer to the Unicode string that contains the new classifier. This classifier is appended to the existing authority portion of
+ /// the peer name of the specified identity. This string is 150 characters long, including the NULL terminator. Specify
+ /// NULL to return the peer name of the identity.
+ ///
+ /// This parameter can only be NULL if pwzIdentity is not NULL.
+ ///
+ ///
+ /// Pointer that receives a pointer to the new peer name. When this string is not required anymore, free it by calling PeerFreeData.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ ///
+ ///
+ /// The parameter ppwzPeername must be set to null before the PeerCreatePeerName function is called.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peercreatepeername NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerCreatePeerName( PCWSTR pwzIdentity, PCWSTR pwzClassifier, PWSTR *ppwzPeerName );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCreatePeerName")]
+ public static extern HRESULT PeerCreatePeerName([Optional, MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwzClassifier,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzPeerName);
+
+ ///
+ /// The PeerEnumGroups function creates and returns a peer enumeration handle used to enumerate all the peer groups
+ /// associated with a specific peer identity.
+ ///
+ /// Specifies the peer identity to enumerate groups for.
+ ///
+ /// Receives a handle to the peer enumeration that contains the list of peer groups that the specified identity is a member of, with
+ /// each item represented as a pointer to a PEER_NAME_PAIR structure. Pass this handle to PeerGetNextItem to retrieve the items;
+ /// when finished, call PeerEndEnumeration release the memory.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_NOT_FOUND
+ /// The specified peer identity cannot be found.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Once the application has obtained the enumeration handle, use PeerGetNextItem and PeerGetItemCount to enumerate the peer groups.
+ ///
+ /// When enumerating peer groups, PeerGetNextItem returns an array of pointers to PEER_NAME_PAIR structures.
+ /// Call PeerEndEnumeration to free the peer enumeration handle when it is no longer required.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peerenumgroups NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerEnumGroups(
+ // PCWSTR pwzIdentity, HPEERENUM *phPeerEnum );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerEnumGroups")]
+ public static extern HRESULT PeerEnumGroups([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, out SafeHPEERENUM phPeerEnum);
+
+ /// The PeerEnumGroups function enumerates all the peer groups associated with a specific peer identity.
+ /// Specifies the peer identity to enumerate groups for.
+ ///
+ /// The peer enumeration that contains the list of peer groups that the specified identity is a member of, with each item
+ /// represented as a pointer to a PEER_NAME_PAIR structure.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peerenumgroups NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerEnumGroups(
+ // PCWSTR pwzIdentity, HPEERENUM *phPeerEnum );
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerEnumGroups")]
+ public static IEnumerable PeerEnumGroups([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity) =>
+ PeerEnum(() => { PeerEnumGroups(pwzIdentity, out var h).ThrowIfFailed(); return h; });
+
+ ///
+ /// The PeerEnumIdentities function creates and returns a peer enumeration handle used to enumerate all the peer identities
+ /// that belong to a specific user.
+ ///
+ ///
+ /// Receives a handle to the peer enumeration that contains the list of peer identities, with each item represented as a pointer to
+ /// a PEER_NAME_PAIR structure. Pass this handle to PeerGetNextItem to retrieve the items; when finished, call PeerEndEnumeration to
+ /// release the memory.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Once the application has obtained the peer enumeration handle, use PeerGetNextItem and PeerGetItemCount to enumerate the peer identities.
+ ///
+ /// When enumerating peer identities, PeerGetNextItem returns an array of pointers to PEER_NAME_PAIR structures.
+ /// Call PeerEndEnumeration to free the enumeration handle when it is no longer required.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peerenumidentities NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerEnumIdentities( HPEERENUM *phPeerEnum );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerEnumIdentities")]
+ public static extern HRESULT PeerEnumIdentities(out SafeHPEERENUM phPeerEnum);
+
+ /// The PeerEnumIdentities function enumerates all the peer identities that belong to a specific user.
+ ///
+ /// The peer enumeration that contains the list of peer identities, with each item represented as a pointer to a PEER_NAME_PAIR
+ /// structure. ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peerenumidentities NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerEnumIdentities( HPEERENUM *phPeerEnum );
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerEnumIdentities")]
+ public static IEnumerable PeerEnumIdentities() =>
+ PeerEnum(() => { PeerEnumIdentities(out var h).ThrowIfFailed(); return h; });
+
+ ///
+ /// The PeerIdentityCreate function creates a new peer identity and returns its name. The name of the peer identity must be
+ /// passed in all subsequent calls to the Peer Identity Manager, Peer Grouping, or PNRP functions that operate on behalf of the peer
+ /// identity. The peer identity name specifies which peer identity is being used.
+ ///
+ ///
+ /// Specifies the classifier to append to the published peer identity name. This string is a Unicode string, and can be NULL.
+ /// This string can only be 150 characters long, including the NULL terminator.
+ ///
+ ///
+ /// Specifies the friendly name of the peer identity. This is a Unicode string, and can be NULL. This string can only be 256
+ /// characters long, including the NULL terminator. If pwzFriendlyName is NULL, the name of the identity is the
+ /// friendly name. The friendly name is optional, and it does not have to be unique.
+ ///
+ ///
+ ///
+ /// Handle to the cryptographic service provider (CSP) that contains an AT_KEYEXCHANGE key pair of at least 1024 bits in length.
+ /// This key pair is used as the basis for a new peer identity. If hCryptProv is zero (0), a new key pair is generated for the peer identity.
+ ///
+ ///
+ /// Note The Identity Manager API does not support a CSP that has user protected keys. If a CSP that has user protected keys
+ /// is used, PeerIdentityCreate returns E_INVALIDARG.
+ ///
+ ///
+ ///
+ /// Receives a pointer to the name of an peer identity that is created. This name must be used in all subsequent calls to the Peer
+ /// Identity Manager, Peer Grouping, or PNRP functions that operate on behalf of the peer identity. Returns NULL if the peer
+ /// identity cannot be created.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The handle to the key specified by hCryptProv is not valid.
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_ALREADY_EXISTS
+ /// The peer identity already exists. Only occurs if an peer identity based on the specified key and classifier already exists.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the peer identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL)
+ /// for the folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
+ ///
+ ///
+ /// -
+ /// PEER_E_TOO_MANY_IDENTITIES
+ /// The peer identity cannot be created because there are too many peer identities.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The key pair and the classifier are used to generate the peer name of a new peer identity. After an peer identity is created, it
+ /// is automatically stored on the disk.
+ ///
+ ///
+ /// The name of the identity should be freed by using PeerFreeData. This does not delete the peer identity. To delete the identity,
+ /// use PeerIdentityDelete function.
+ ///
+ /// If hCryptProv is not NULL, it can be released by using CryptReleaseContext after the call returns.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peeridentitycreate NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerIdentityCreate( PCWSTR pwzClassifier, PCWSTR pwzFriendlyName, HCRYPTPROV hCryptProv, PWSTR *ppwzIdentity );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerIdentityCreate")]
+ public static extern HRESULT PeerIdentityCreate([Optional, MarshalAs(UnmanagedType.LPWStr)] string pwzClassifier,
+ [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwzFriendlyName, [In, Optional] HCRYPTPROV hCryptProv,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzIdentity);
+
+ ///
+ /// The PeerIdentityDelete function permanently deletes a peer identity. This includes removing all certificates, private
+ /// keys, and all group information associated with a specified peer identity.
+ ///
+ /// Specifies a peer identity to delete.
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// The parameter is not valid.
+ ///
+ /// -
+ /// PEER_E_GROUPS_EXIST
+ ///
+ /// The peer identity cannot be deleted because it has peer groups associated with it. All peer groups associated with the specified
+ /// identity must be deleted by using PeerGroupDelete before a call to PeerIdentityDelete can succeed.
+ ///
+ ///
+ /// -
+ /// PEER_E_NOT_FOUND
+ /// A peer identity that matches the specified name cannot be found.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peeridentitydelete NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerIdentityDelete( PCWSTR pwzIdentity );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerIdentityDelete")]
+ public static extern HRESULT PeerIdentityDelete([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity);
+
+ ///
+ /// The PeerIdentityExport function allows a user to export one peer identity. The user can then transfer the peer identity
+ /// to a different computer.
+ ///
+ /// Specifies the peer identity to export. This parameter is required and does not have a default value.
+ ///
+ /// Specifies the password to use to encrypt the peer identity. This parameter cannot be NULL. This password must also be
+ /// used to import the peer identity, or the import operation fails.
+ ///
+ ///
+ /// Receives a pointer to the exported peer identity in XML format. If the export operation is successful, the application must free
+ /// ppwzExportXML by calling PeerFreeData.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the peer identity or peer group keys was denied. This is typically caused by an incorrect access control list (ACL)
+ /// for the folder that contains the user or computer keys. This can happen when the ACL has been manually reset.
+ ///
+ ///
+ /// -
+ /// PEER_E_NOT_FOUND
+ /// The specified peer identity does not exist.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Peer-to-peer group membership credentials are not exported. Only one peer identity is exported. An exported peer identity can be
+ /// imported on another computer by using PeerIdentityImport.
+ ///
+ ///
+ /// Exporting a peer identity does not remove it from a local ccmputer, it makes a copy of it. The copy can be used to backup and
+ /// restore a peer identity.
+ ///
+ /// The XML fragment used by PeerIdentityExport is as follows:
+ ///
+ /// <PEERIDENTITYEXPORT VERSION="1.0"> <PEERNAME> <!-- UTF-8 encoded peer name of the identity --> </PEERNAME> <DATA xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64"> <!-- base64 encoded / PFX encoded and encrypted IDC with the private key --> </DATA> </PEERIDENTITYEXPORT>
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peeridentityexport NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerIdentityExport( PCWSTR pwzIdentity, PCWSTR pwzPassword, PWSTR *ppwzExportXML );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerIdentityExport")]
+ public static extern HRESULT PeerIdentityExport([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, [MarshalAs(UnmanagedType.LPWStr)] string pwzPassword,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzExportXML);
+
+ /// The PeerIdentityGetCryptKey function retrieves a handle to a cryptographic service provider (CSP).
+ /// Specifies the peer identity to retrieve the key pair for.
+ ///
+ /// Receives a pointer to the handle of the cryptographic service provider (CSP) that contains an AT_KEYEXCHANGE RSA key pair.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the peer identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL)
+ /// for the folder that contains the user or computer keys. This can happen when the ACL has been manually reset.
+ ///
+ ///
+ /// -
+ /// PEER_E_NOT_FOUND
+ /// An identity that matches the specified name cannot be found.
+ ///
+ ///
+ ///
+ ///
+ /// The key can be retrieved by calling CryptGetUserKey.
+ /// When the handle is not required anymore, the application is responsible for releasing the handle by using .
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peeridentitygetcryptkey NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerIdentityGetCryptKey( PCWSTR pwzIdentity, HCRYPTPROV *phCryptProv );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerIdentityGetCryptKey")]
+ public static extern HRESULT PeerIdentityGetCryptKey([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, out SafeHCRYPTPROV phCryptProv);
+
+ /// The PeerIdentityGetDefault function retrieves the default peer name set for the current user.
+ ///
+ /// Pointer to the address of a zero-terminated Unicode string that contains the default name of the current user.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_NOT_FOUND
+ /// A peer identity that matches the specified name cannot be found.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peeridentitygetdefault NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerIdentityGetDefault( PWSTR *ppwzPeerName );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerIdentityGetDefault")]
+ public static extern HRESULT PeerIdentityGetDefault([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzPeerName);
+
+ /// The PeerIdentityGetFriendlyName function returns the friendly name of the peer identity.
+ /// Specifies the peer identity to obtain a friendly name.
+ ///
+ /// Receives a pointer to the friendly name. When ppwzFriendlyName is not required anymore, the application is responsible for
+ /// freeing this string by calling PeerFreeData.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the peer identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL)
+ /// for the folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
+ ///
+ ///
+ /// -
+ /// PEER_E_NOT_FOUND
+ /// A peer identity that matches the specified name cannot be found.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peeridentitygetfriendlyname NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerIdentityGetFriendlyName( PCWSTR pwzIdentity, PWSTR *ppwzFriendlyName );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerIdentityGetFriendlyName")]
+ public static extern HRESULT PeerIdentityGetFriendlyName([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzFriendlyName);
+
+ ///
+ /// The PeerIdentityGetXML function returns a description of the peer identity, which can then be passed to third parties and
+ /// used to invite a peer identity into a peer group. This information is returned as an XML fragment.
+ ///
+ ///
+ /// Specifies the peer identity to retrieve peer identity information for. When this parameter is passed as NULL, a "default"
+ /// identity will be generated for the user by the peer infrastructure.
+ ///
+ ///
+ /// Pointer to a pointer to a Unicode string that contains the XML fragment. When ppwzIdentityXML is no longer required, the
+ /// application is responsible for freeing this string by calling PeerFreeData.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_HANDLE
+ /// The handle to the identity is invalid.
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ ///
+ ///
+ ///
+ /// The XML fragment returned has the following structure:
+ ///
+ /// <PEERIDENTITYINFO VERSION="1.0"> <IDC xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64"> Base 64 encoded certificate. </IDC> </PEERIDENTITYINFO>
+ ///
+ /// This XML fragment is used when creating an invitation to join a group.
+ ///
+ /// Applications are not allowed to add tags within the PEERIDENTITYINFO tag or modify this XML fragment in any way.
+ /// Applications are allowed to incorporate this XML fragment into other XML documents, but must strip out all application-specific
+ /// XML before passing this fragment to the PeerGroupCreateInvitation.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peeridentitygetxml NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerIdentityGetXML( PCWSTR pwzIdentity, PWSTR *ppwzIdentityXML );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerIdentityGetXML")]
+ public static extern HRESULT PeerIdentityGetXML([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzIdentityXML);
+
+ ///
+ /// The PeerIdentityImport function imports one peer identity. If the peer identity exists on a computer,
+ /// PEER_E_ALREADY_EXISTS is returned.
+ ///
+ ///
+ /// Pointer to the XML format peer identity to import, which is returned by PeerIdentityExport. This binary data must match the
+ /// exported data byte-for-byte. The XML must remain valid XML with no extra characters.
+ ///
+ ///
+ /// Specifies the password to use to de-crypt a peer identity. The password must be identical to the password supplied to
+ /// PeerIdentityExport. This parameter cannot be NULL.
+ ///
+ ///
+ /// Pointer to a string that represents a peer identity that is imported. If the import operation is successful, the application
+ /// must free ppwzIdentity by calling PeerFreeData.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid, or the XML data in ppwzImportXML has been tampered with.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_ALREADY_EXISTS
+ /// The peer identity already exists on this computer.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the peer identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL)
+ /// for the folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The XML fragment used by PeerIdentityImport is as follows:
+ ///
+ /// <PEERIDENTITYEXPORT VERSION="1.0"> <IDENTITY> <!-- UTF-8 encoded peer name of the identity --> </IDENTITY> <IDENTITYDATA xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="bin.base64"> <!-- base64 encoded / PFX encoded and encrypted IDC with the private key --> </IDENTTYDATA> </PEERIDENTITYEXPORT>
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peeridentityimport NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerIdentityImport( PCWSTR pwzImportXML, PCWSTR pwzPassword, PWSTR *ppwzIdentity );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerIdentityImport")]
+ public static extern HRESULT PeerIdentityImport([MarshalAs(UnmanagedType.LPWStr)] string pwzImportXML, [MarshalAs(UnmanagedType.LPWStr)] string pwzPassword,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStringMarshaler))] out string ppwzIdentity);
+
+ ///
+ /// The PeerIdentitySetFriendlyName function modifies the friendly name for a specified peer identity. The friendly name is
+ /// the human-readable name.
+ ///
+ /// Specifies a peer identity to modify.
+ ///
+ /// Specifies a new friendly name. Specify NULL or an empty string to reset a friendly name to the default value, which is
+ /// the Unicode version of the peer name.
+ ///
+ ///
+ /// If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// E_INVALIDARG
+ /// One of the parameters is not valid.
+ ///
+ /// -
+ /// E_OUTOFMEMORY
+ /// There is not enough memory to perform the specified operation.
+ ///
+ /// -
+ /// PEER_E_NO_KEY_ACCESS
+ ///
+ /// Access to the peer identity or peer group keys is denied. Typically, this is caused by an incorrect access control list (ACL)
+ /// for the folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
+ ///
+ ///
+ /// -
+ /// PEER_E_NOT_FOUND
+ /// A peer identity that matches a specified name cannot be found.
+ ///
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/nf-p2p-peeridentitysetfriendlyname NOT_BUILD_WINDOWS_DEPRECATE HRESULT
+ // PeerIdentitySetFriendlyName( PCWSTR pwzIdentity, PCWSTR pwzFriendlyName );
+ [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerIdentitySetFriendlyName")]
+ public static extern HRESULT PeerIdentitySetFriendlyName([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pwzFriendlyName);
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/P2P/P2P.cs b/PInvoke/P2P/P2P.cs
new file mode 100644
index 00000000..cb012e5a
--- /dev/null
+++ b/PInvoke/P2P/P2P.cs
@@ -0,0 +1,2877 @@
+using System;
+using System.Runtime.InteropServices;
+using Vanara.InteropServices;
+using static Vanara.PInvoke.Ws2_32;
+using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the P2P.dll
+ public static partial class P2P
+ {
+ private const string Lib_P2P = "P2P.dll";
+ private const string Lib_P2PGraph = "p2pgraph.dll";
+
+ /// The PEER_APPLICATION_REGISTRATION_TYPE enumeration defines the set of peer application registration flags.
+ ///
+ ///
+ /// "Peer application" defines the set of software applications or components available for use with the peer collaboration network.
+ /// The peer collaboration network enables participants in the network to initiate usage of this application.
+ ///
+ ///
+ /// Applications with the same GUID and registered for the current user take precedence over applications with that same GUID
+ /// registered for all users.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_application_registration_type typedef enum
+ // peer_application_registration_type_tag { PEER_APPLICATION_CURRENT_USER, PEER_APPLICATION_ALL_USERS } PEER_APPLICATION_REGISTRATION_TYPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_application_registration_type_tag")]
+ public enum PEER_APPLICATION_REGISTRATION_TYPE
+ {
+ /// The application is available only to the current user account logged into the machine.
+ PEER_APPLICATION_CURRENT_USER,
+
+ /// The application is available to all user accounts set on the machine.
+ PEER_APPLICATION_ALL_USERS,
+ }
+
+ ///
+ /// The PEER_CHANGE_TYPE enumeration defines the set of changes that were performed on a peer object, endpoint, or
+ /// application in a peer event. It is used to qualify the peer event associated with the change type.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_change_type typedef enum peer_change_type_tag {
+ // PEER_CHANGE_ADDED, PEER_CHANGE_DELETED, PEER_CHANGE_UPDATED } PEER_CHANGE_TYPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_change_type_tag")]
+ public enum PEER_CHANGE_TYPE
+ {
+ /// The peer object, endpoint, or application has been added.
+ PEER_CHANGE_ADDED,
+
+ /// The peer object, endpoint, or application has been deleted.
+ PEER_CHANGE_DELETED,
+
+ /// The peer object, endpoint, or application has been updated with new information.
+ PEER_CHANGE_UPDATED,
+ }
+
+ ///
+ /// The PEER_COLLAB_EVENT_TYPE enumeration defines the set of events that can be raised on a peer by the peer collaboration
+ /// network event infrastructure.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_collab_event_type typedef enum peer_collab_event_type_tag {
+ // PEER_EVENT_WATCHLIST_CHANGED, PEER_EVENT_ENDPOINT_CHANGED, PEER_EVENT_ENDPOINT_PRESENCE_CHANGED,
+ // PEER_EVENT_ENDPOINT_APPLICATION_CHANGED, PEER_EVENT_ENDPOINT_OBJECT_CHANGED, PEER_EVENT_MY_ENDPOINT_CHANGED,
+ // PEER_EVENT_MY_PRESENCE_CHANGED, PEER_EVENT_MY_APPLICATION_CHANGED, PEER_EVENT_MY_OBJECT_CHANGED,
+ // PEER_EVENT_PEOPLE_NEAR_ME_CHANGED, PEER_EVENT_REQUEST_STATUS_CHANGED } PEER_COLLAB_EVENT_TYPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_collab_event_type_tag")]
+ public enum PEER_COLLAB_EVENT_TYPE
+ {
+ /// The peer's list of watched contacts has changed.
+ PEER_EVENT_WATCHLIST_CHANGED = 1,
+
+ /// The endpoint has changed.
+ PEER_EVENT_ENDPOINT_CHANGED,
+
+ /// The presence status of an endpoint has changed.
+ PEER_EVENT_ENDPOINT_PRESENCE_CHANGED,
+
+ /// The registered application of the endpoint has changed.
+ PEER_EVENT_ENDPOINT_APPLICATION_CHANGED,
+
+ /// A peer object registered to the endpoint has changed.
+ PEER_EVENT_ENDPOINT_OBJECT_CHANGED,
+
+ /// The local peer's endpoint has changed.
+ PEER_EVENT_MY_ENDPOINT_CHANGED,
+
+ /// The local peer's presence status has changed.
+ PEER_EVENT_MY_PRESENCE_CHANGED,
+
+ /// The local peer's registered application has changed.
+ PEER_EVENT_MY_APPLICATION_CHANGED,
+
+ /// A peer object registered with the local peer has changed.
+ PEER_EVENT_MY_OBJECT_CHANGED,
+
+ /// An endpoint in the same subnet as the local peer's endpoint has changed.
+ PEER_EVENT_PEOPLE_NEAR_ME_CHANGED,
+
+ /// The status of a request to refresh endpoint data or subscribe to endpoint data has changed.
+ PEER_EVENT_REQUEST_STATUS_CHANGED,
+ }
+
+ /// The PEER_CONNECTION_FLAGS enumeration specifies the types of connections that a peer can have.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_connection_flags typedef enum peer_connection_flags_tag {
+ // PEER_CONNECTION_NEIGHBOR, PEER_CONNECTION_DIRECT } PEER_CONNECTION_FLAGS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_connection_flags_tag")]
+ [Flags]
+ public enum PEER_CONNECTION_FLAGS
+ {
+ /// Specifies that a connection is a neighbor connection.
+ PEER_CONNECTION_NEIGHBOR = 0x0001,
+
+ /// Specifies that a connection is a direct connection to another node.
+ PEER_CONNECTION_DIRECT = 0x0002,
+ }
+
+ /// The PEER_CONNECTION_STATUS enumeration specifies the status of a peer direct or neighbor connection.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_connection_status typedef enum peer_connection_status_tag {
+ // PEER_CONNECTED, PEER_DISCONNECTED, PEER_CONNECTION_FAILED } PEER_CONNECTION_STATUS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_connection_status_tag")]
+ public enum PEER_CONNECTION_STATUS
+ {
+ /// The peer is connected to another peer.
+ PEER_CONNECTED = 1,
+
+ /// The peer has disconnected from another peer.
+ PEER_DISCONNECTED,
+
+ /// The peer failed to connect to another peer.
+ PEER_CONNECTION_FAILED,
+ }
+
+ /// The PEER_GRAPH_EVENT_TYPE enumeration specifies peer event types the application is to be notified for.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_graph_event_type typedef enum peer_graph_event_type_tag {
+ // PEER_GRAPH_EVENT_STATUS_CHANGED, PEER_GRAPH_EVENT_PROPERTY_CHANGED, PEER_GRAPH_EVENT_RECORD_CHANGED,
+ // PEER_GRAPH_EVENT_DIRECT_CONNECTION, PEER_GRAPH_EVENT_NEIGHBOR_CONNECTION, PEER_GRAPH_EVENT_INCOMING_DATA,
+ // PEER_GRAPH_EVENT_CONNECTION_REQUIRED, PEER_GRAPH_EVENT_NODE_CHANGED, PEER_GRAPH_EVENT_SYNCHRONIZED } PEER_GRAPH_EVENT_TYPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_graph_event_type_tag")]
+ public enum PEER_GRAPH_EVENT_TYPE
+ {
+ /// The peer graph status has changed in some manner. For example, the node has synchronized with the peer graph.
+ PEER_GRAPH_EVENT_STATUS_CHANGED = 1,
+
+ ///
+ /// A field in the peer graph property structure has changed. This peer event does not generate a specific piece of data for an
+ /// application to retrieve. The application must use PeerGraphGetProperties to obtain the updated structure.
+ ///
+ PEER_GRAPH_EVENT_PROPERTY_CHANGED,
+
+ /// A record type or specific record has changed in some manner.
+ PEER_GRAPH_EVENT_RECORD_CHANGED,
+
+ /// A peer's direct connection has changed.
+ PEER_GRAPH_EVENT_DIRECT_CONNECTION,
+
+ /// A connection to a peer neighbor has changed.
+ PEER_GRAPH_EVENT_NEIGHBOR_CONNECTION,
+
+ /// Data has been received from a direct or neighbor connection.
+ PEER_GRAPH_EVENT_INCOMING_DATA,
+
+ ///
+ /// The peer graph has become unstable. The client should call PeerGraphConnect on a new node. This peer event does not generate
+ /// a specific piece of data for an application to retrieve.
+ ///
+ PEER_GRAPH_EVENT_CONNECTION_REQUIRED,
+
+ /// A node's presence status has changed in the peer graph.
+ PEER_GRAPH_EVENT_NODE_CHANGED,
+
+ /// A specific record type has been synchronized.
+ PEER_GRAPH_EVENT_SYNCHRONIZED,
+ }
+
+ /// The PEER_GRAPH_PROPERTY_FLAGS enumeration specifies properties of a peer graph.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_graph_property_flags typedef enum
+ // peer_graph_property_flags_tag { PEER_GRAPH_PROPERTY_HEARTBEATS, PEER_GRAPH_PROPERTY_DEFER_EXPIRATION } PEER_GRAPH_PROPERTY_FLAGS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_graph_property_flags_tag")]
+ [Flags]
+ public enum PEER_GRAPH_PROPERTY_FLAGS
+ {
+ /// Reserved.
+ PEER_GRAPH_PROPERTY_HEARTBEATS = 0x01,
+
+ /// Graph records are not expired until the peer connects with a graph.
+ PEER_GRAPH_PROPERTY_DEFER_EXPIRATION = 0x02,
+ }
+
+ /// The PEER_GRAPH_SCOPE enumeration specifies the network scope of a peer graph.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_graph_scope typedef enum peer_graph_scope_tag {
+ // PEER_GRAPH_SCOPE_ANY, PEER_GRAPH_SCOPE_GLOBAL, PEER_GRAPH_SCOPE_SITELOCAL, PEER_GRAPH_SCOPE_LINKLOCAL, PEER_GRAPH_SCOPE_LOOPBACK
+ // } PEER_GRAPH_SCOPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_graph_scope_tag")]
+ public enum PEER_GRAPH_SCOPE
+ {
+ /// The peer graph's network scope can contain any IP address, valid or otherwise.
+ PEER_GRAPH_SCOPE_ANY = 0,
+
+ /// The IP addresses for the peer graph's network scope can be from any unblocked address range.
+ PEER_GRAPH_SCOPE_GLOBAL,
+
+ /// The IP addresses for the peer graph's network scope must be within the IP range defined for the site.
+ PEER_GRAPH_SCOPE_SITELOCAL,
+
+ /// The IP addresses for the peer graph's network scope must be within the IP range defined for the local area network.
+ PEER_GRAPH_SCOPE_LINKLOCAL,
+
+ /// The peer graph's network scope is the local computer's loopback IP address.
+ PEER_GRAPH_SCOPE_LOOPBACK,
+ }
+
+ ///
+ /// The PEER_GRAPH_STATUS_FLAGS enumeration is a set of flags that show the current status of a node within the peer graph.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_graph_status_flags typedef enum peer_graph_status_flags_tag {
+ // PEER_GRAPH_STATUS_LISTENING, PEER_GRAPH_STATUS_HAS_CONNECTIONS, PEER_GRAPH_STATUS_SYNCHRONIZED } PEER_GRAPH_STATUS_FLAGS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_graph_status_flags_tag")]
+ [Flags]
+ public enum PEER_GRAPH_STATUS_FLAGS
+ {
+ /// Specifies whether or not the node is listening for connections.
+ PEER_GRAPH_STATUS_LISTENING = 0x0001,
+
+ /// Specifies whether or not the node has connections to other nodes.
+ PEER_GRAPH_STATUS_HAS_CONNECTIONS = 0x0002,
+
+ /// Specifies whether or not the node's database is synchronized.
+ PEER_GRAPH_STATUS_SYNCHRONIZED = 0x0004,
+ }
+
+ ///
+ /// The PEER_GROUP_AUTHENTICATION_SCHEME enumeration defines the set of possible authentication schemes that can be used to
+ /// authenticate peers joining a peer group.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_group_authentication_scheme typedef enum
+ // peer_group_authentication_scheme_tag { PEER_GROUP_GMC_AUTHENTICATION, PEER_GROUP_PASSWORD_AUTHENTICATION } PEER_GROUP_AUTHENTICATION_SCHEME;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_group_authentication_scheme_tag")]
+ [Flags]
+ public enum PEER_GROUP_AUTHENTICATION_SCHEME
+ {
+ /// Authentication is performed using Group Membership Certificates (GMC).
+ PEER_GROUP_GMC_AUTHENTICATION = 0x00000001,
+
+ /// Authentication is performed by validating a provided password.
+ PEER_GROUP_PASSWORD_AUTHENTICATION = 0x00000002,
+ }
+
+ ///
+ /// The PEER_GROUP_EVENT_TYPE enumeration contains the specific peer event types that can occur within a peer group.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_group_event_type typedef enum peer_group_event_type_tag {
+ // PEER_GROUP_EVENT_STATUS_CHANGED, PEER_GROUP_EVENT_PROPERTY_CHANGED, PEER_GROUP_EVENT_RECORD_CHANGED,
+ // PEER_GROUP_EVENT_DIRECT_CONNECTION, PEER_GROUP_EVENT_NEIGHBOR_CONNECTION, PEER_GROUP_EVENT_INCOMING_DATA,
+ // PEER_GROUP_EVENT_MEMBER_CHANGED, PEER_GROUP_EVENT_CONNECTION_FAILED, PEER_GROUP_EVENT_AUTHENTICATION_FAILED } PEER_GROUP_EVENT_TYPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_group_event_type_tag")]
+ public enum PEER_GROUP_EVENT_TYPE
+ {
+ ///
+ /// The status of the group has changed. This peer event is fired when one of the flags listed in the PEER_GROUP_STATUS
+ /// enumeration are set or changed for the group.
+ ///
+ PEER_GROUP_EVENT_STATUS_CHANGED = 1,
+
+ /// A member in the PEER_GROUP_EVENT_DATA to retrieve.
+ PEER_GROUP_EVENT_PROPERTY_CHANGED,
+
+ /// A group record has changed. Information on this change is provided in the PEER_GROUP_EVENT_DATA.
+ PEER_GROUP_EVENT_RECORD_CHANGED,
+
+ /// The status of a direct connection has changed. Information on this change is provided in the PEER_GROUP_EVENT_DATA.
+ PEER_GROUP_EVENT_DIRECT_CONNECTION,
+
+ /// The status of a neighbor connection has changed. Information on this change is provided in the PEER_GROUP_EVENT_DATA.
+ PEER_GROUP_EVENT_NEIGHBOR_CONNECTION,
+
+ ///
+ /// Incoming direct connection data from a member is detected. Information on this peer event is provided in the PEER_GROUP_EVENT_DATA.
+ ///
+ PEER_GROUP_EVENT_INCOMING_DATA,
+
+ /// The status of a member has changed. Information on this change is provided in the PEER_GROUP_EVENT_DATA.
+ PEER_GROUP_EVENT_MEMBER_CHANGED,
+
+ ///
+ /// The connection to the peer group has failed. No data is provided when this peer event is raised. This event is also raised
+ /// if no members are online in a group you are attempting to connect to for the first time.
+ ///
+ PEER_GROUP_EVENT_CONNECTION_FAILED,
+
+ ///
+ PEER_GROUP_EVENT_AUTHENTICATION_FAILED,
+ }
+
+ /// The PEER_GROUP_ISSUE_CREDENTIAL_FLAGS are used to specify if user credentials are stored within a group.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_group_issue_credential_flags typedef enum
+ // peer_issue_credential_flags_tag { PEER_GROUP_STORE_CREDENTIALS } PEER_GROUP_ISSUE_CREDENTIAL_FLAGS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_issue_credential_flags_tag")]
+ [Flags]
+ public enum PEER_GROUP_ISSUE_CREDENTIAL_FLAGS
+ {
+ ///
+ /// When the PEER_GROUP_STORE_CREDENTIALS flag is set, the user credentials are stored within a group database to be retrieved
+ /// when the user connects. If the flag is not set, any new credentials are returned in string form and must be passed to the
+ /// user out-of-band.
+ ///
+ PEER_GROUP_STORE_CREDENTIALS = 0x0001,
+ }
+
+ /// The PEER_GROUP_PROPERTY_FLAGS flags are used to specify various peer group membership settings.
+ /// These flags can only be set by the peer group creator.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_group_property_flags typedef enum
+ // peer_group_property_flags_tag { PEER_MEMBER_DATA_OPTIONAL, PEER_DISABLE_PRESENCE, PEER_DEFER_EXPIRATION } PEER_GROUP_PROPERTY_FLAGS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_group_property_flags_tag")]
+ public enum PEER_GROUP_PROPERTY_FLAGS
+ {
+ ///
+ /// A peer's member data (PEER_MEMBER) is only published when an action if performed, such as publishing a record or issuing a
+ /// GMC. If the peer has not performed one of these actions, the membership data will not be available.
+ ///
+ PEER_MEMBER_DATA_OPTIONAL = 0x0001,
+
+ /// The peer presence system is prevented from automatically publishing presence information.
+ PEER_DISABLE_PRESENCE = 0x0002,
+
+ /// Group records are not expired until the peer connects with a group.
+ PEER_DEFER_EXPIRATION = 0x0004,
+ }
+
+ /// The PEER_GROUP_STATUS flags indicate whether or not the peer group has connections present.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_group_status typedef enum peer_group_status_tag {
+ // PEER_GROUP_STATUS_LISTENING, PEER_GROUP_STATUS_HAS_CONNECTIONS } PEER_GROUP_STATUS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_group_status_tag")]
+ [Flags]
+ public enum PEER_GROUP_STATUS
+ {
+ /// The peer group is awaiting new connections.
+ PEER_GROUP_STATUS_LISTENING = 0x0001,
+
+ /// The peer group has at least one connection.
+ PEER_GROUP_STATUS_HAS_CONNECTIONS = 0x0002,
+ }
+
+ ///
+ /// The PEER_INVITATION_RESPONSE_TYPE enumeration defines the type of response received to an invitation to start a Peer
+ /// Collaboration activity.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_invitation_response_type typedef enum
+ // peer_invitation_response_type_tag { PEER_INVITATION_RESPONSE_DECLINED, PEER_INVITATION_RESPONSE_ACCEPTED,
+ // PEER_INVITATION_RESPONSE_EXPIRED, PEER_INVITATION_RESPONSE_ERROR } PEER_INVITATION_RESPONSE_TYPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_invitation_response_type_tag")]
+ public enum PEER_INVITATION_RESPONSE_TYPE
+ {
+ /// The invitation was declined by the peer.
+ PEER_INVITATION_RESPONSE_DECLINED,
+
+ /// The invitation was accepted by the peer.
+ PEER_INVITATION_RESPONSE_ACCEPTED,
+
+ /// The invitation has expired.
+ PEER_INVITATION_RESPONSE_EXPIRED,
+
+ /// An error occurred during the invitation process.
+ PEER_INVITATION_RESPONSE_ERROR,
+ }
+
+ ///
+ /// The PEER_MEMBER_CHANGE_TYPE enumeration defines the set of possible peer group membership and presence states for a peer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_member_change_type typedef enum peer_member_change_type_tag {
+ // PEER_MEMBER_CONNECTED, PEER_MEMBER_DISCONNECTED, PEER_MEMBER_UPDATED, PEER_MEMBER_JOINED, PEER_MEMBER_LEFT } PEER_MEMBER_CHANGE_TYPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_member_change_type_tag")]
+ public enum PEER_MEMBER_CHANGE_TYPE
+ {
+ /// A member is connected to a peer group.
+ PEER_MEMBER_CONNECTED = 1,
+
+ /// A member is disconnected from a peer group.
+ PEER_MEMBER_DISCONNECTED,
+
+ /// A member has updated information (for example, a new address) within a peer group.
+ PEER_MEMBER_UPDATED,
+
+ ///
+ /// New membership information is published for a group member. The peer name of a peer group member is obtained from the
+ /// pwzIdentity field of the PEER_EVENT_MEMBER_CHANGE_DATA structure. New membership information is published in one of the
+ /// following three scenarios:
+ ///
+ PEER_MEMBER_JOINED,
+
+ /// This peer event does not exist in the Peer Grouping Infrastructure v1.0, and must not be used.
+ PEER_MEMBER_LEFT,
+ }
+
+ ///
+ /// The PEER_MEMBER_FLAGS flag allows an application to specify whether all members or only present ones should be enumerated
+ /// when the PeerGroupEnumMembers function is called, or to indicate whether or not a member is present within the peer group.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_member_flags typedef enum peer_member_flags_tag {
+ // PEER_MEMBER_PRESENT } PEER_MEMBER_FLAGS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_member_flags_tag")]
+ [Flags]
+ public enum PEER_MEMBER_FLAGS
+ {
+ /// The member is present in the peer group.
+ PEER_MEMBER_PRESENT = 0x01,
+ }
+
+ /// The PEER_NODE_CHANGE_TYPE enumeration specifies the types of peer node graph status changes.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_node_change_type typedef enum peer_node_change_type_tag {
+ // PEER_NODE_CHANGE_CONNECTED, PEER_NODE_CHANGE_DISCONNECTED, PEER_NODE_CHANGE_UPDATED } PEER_NODE_CHANGE_TYPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_node_change_type_tag")]
+ public enum PEER_NODE_CHANGE_TYPE
+ {
+ /// The peer node has connected to the graph.
+ PEER_NODE_CHANGE_CONNECTED = 1,
+
+ /// The peer node has disconnected from the graph.
+ PEER_NODE_CHANGE_DISCONNECTED,
+
+ /// The peer node's status within the graph has changed.
+ PEER_NODE_CHANGE_UPDATED,
+ }
+
+ ///
+ /// The PEER_PRESENCE_STATUS enumeration defines the set of possible presence status settings available to a peer that
+ /// participates in a peer collaboration network. These settings can be set by a peer collaboration network endpoint to indicate the
+ /// peer's current level of participation to its watchers.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_presence_status typedef enum peer_presence_status_tag {
+ // PEER_PRESENCE_OFFLINE, PEER_PRESENCE_OUT_TO_LUNCH, PEER_PRESENCE_AWAY, PEER_PRESENCE_BE_RIGHT_BACK, PEER_PRESENCE_IDLE,
+ // PEER_PRESENCE_BUSY, PEER_PRESENCE_ON_THE_PHONE, PEER_PRESENCE_ONLINE } PEER_PRESENCE_STATUS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_presence_status_tag")]
+ public enum PEER_PRESENCE_STATUS
+ {
+ /// The user is offline.
+ PEER_PRESENCE_OFFLINE,
+
+ /// The user is currently "out to lunch" and unable to respond.
+ PEER_PRESENCE_OUT_TO_LUNCH,
+
+ /// The user is away and unable to respond.
+ PEER_PRESENCE_AWAY,
+
+ /// The user has stepped away from the application and will participate soon.
+ PEER_PRESENCE_BE_RIGHT_BACK,
+
+ /// The user is idling.
+ PEER_PRESENCE_IDLE,
+
+ /// The user is busy and does not wish to be disturbed.
+ PEER_PRESENCE_BUSY,
+
+ /// The user is currently on the phone and does not wish to be disturbed.
+ PEER_PRESENCE_ON_THE_PHONE,
+
+ /// The user is actively participating in the peer collaboration network.
+ PEER_PRESENCE_ONLINE,
+ }
+
+ /// The PEER_PUBLICATION_SCOPE enumeration defines the set of scopes for the publication of peer objects or data.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_publication_scope typedef enum peer_publication_scope_tag {
+ // PEER_PUBLICATION_SCOPE_NONE, PEER_PUBLICATION_SCOPE_NEAR_ME, PEER_PUBLICATION_SCOPE_INTERNET, PEER_PUBLICATION_SCOPE_ALL } PEER_PUBLICATION_SCOPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_publication_scope_tag")]
+ [Flags]
+ public enum PEER_PUBLICATION_SCOPE
+ {
+ /// No scope is set for the publication of this data.
+ PEER_PUBLICATION_SCOPE_NONE = 0x0,
+
+ /// The data is published to peers in the same logical or virtual subnet.
+ PEER_PUBLICATION_SCOPE_NEAR_ME = 0x1,
+
+ /// The data is published to peers on the Internet.
+ PEER_PUBLICATION_SCOPE_INTERNET = 0x2,
+
+ /// The data is published to all peers.
+ PEER_PUBLICATION_SCOPE_ALL = PEER_PUBLICATION_SCOPE_NEAR_ME | PEER_PUBLICATION_SCOPE_INTERNET,
+ }
+
+ /// The PEER_RECORD_CHANGE_TYPE enumeration specifies the changes that can occur to a record.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_record_change_type typedef enum peer_record_change_type_tag {
+ // PEER_RECORD_ADDED, PEER_RECORD_UPDATED, PEER_RECORD_DELETED, PEER_RECORD_EXPIRED } PEER_RECORD_CHANGE_TYPE;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_record_change_type_tag")]
+ public enum PEER_RECORD_CHANGE_TYPE
+ {
+ /// Indicates that the specified record is added to the peer graph or group.
+ PEER_RECORD_ADDED = 1,
+
+ /// Indicates that the specified record is updated in the peer graph or group.
+ PEER_RECORD_UPDATED,
+
+ /// Indicates that the specified record is deleted from the peer graph or group.
+ PEER_RECORD_DELETED,
+
+ /// Indicates that the specified record is expired and removed from the peer graph or group.
+ PEER_RECORD_EXPIRED,
+ }
+
+ /// The PEER_RECORD_FLAGS enumeration specifies a set of flags for peer record behaviors.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_record_flags typedef enum peer_record_flags_tag {
+ // PEER_RECORD_FLAG_AUTOREFRESH, PEER_RECORD_FLAG_DELETED } PEER_RECORD_FLAGS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_record_flags_tag")]
+ [Flags]
+ public enum PEER_RECORD_FLAGS
+ {
+ /// The peer record must be automatically refreshed any time an event for the record is raised.
+ PEER_RECORD_FLAG_AUTOREFRESH = 0x0001,
+
+ /// The peer record is marked for deletion but has not yet been physically removed from the local computer.
+ PEER_RECORD_FLAG_DELETED = 0x0002,
+ }
+
+ ///
+ /// The PEER_SIGNIN_FLAGS enumeration defines the set of peer presence publication behaviors available when the peer signs in
+ /// to a peer collaboration network.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_signin_flags typedef enum peer_signin_flags_tag {
+ // PEER_SIGNIN_NONE, PEER_SIGNIN_NEAR_ME, PEER_SIGNIN_INTERNET, PEER_SIGNIN_ALL } PEER_SIGNIN_FLAGS;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_signin_flags_tag")]
+ [Flags]
+ public enum PEER_SIGNIN_FLAGS
+ {
+ /// A peer's presence is not being published in any scope.
+ PEER_SIGNIN_NONE = 0x0,
+
+ ///
+ /// The peer can publish availability information to endpoints in the same subnet or local area network, or query for other
+ /// endpoints available on the subnet.
+ ///
+ PEER_SIGNIN_NEAR_ME = 0x1,
+
+ /// The peer can publish presence, applications, and objects to all contacts in a peer's contact list.
+ PEER_SIGNIN_INTERNET = 0x2,
+
+ ///
+ /// The peer can publish presence, applications, and objects to all contacts in a peer's contact list, or query for other
+ /// endpoints available on the subnet.
+ ///
+ PEER_SIGNIN_ALL = PEER_SIGNIN_NEAR_ME | PEER_SIGNIN_INTERNET,
+ }
+
+ ///
+ /// The PEER_WATCH_PERMISSION enumeration defines whether a peer contact can receive presence updates from a contact.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ne-p2p-peer_watch_permission typedef enum peer_watch_permission_tag {
+ // PEER_WATCH_BLOCKED, PEER_WATCH_ALLOWED } PEER_WATCH_PERMISSION;
+ [PInvokeData("p2p.h", MSDNShortId = "NE:p2p.peer_watch_permission_tag")]
+ public enum PEER_WATCH_PERMISSION
+ {
+ /// The peer contact cannot receive presence updates.
+ PEER_WATCH_BLOCKED,
+
+ /// The peer contact can receive presence updates.
+ PEER_WATCH_ALLOWED,
+ }
+
+ /// The PNRP_CLOUD_FLAGS enumeration specifies the validity of a cloud name.
+ // https://docs.microsoft.com/en-us/windows/win32/api/pnrpdef/ne-pnrpdef-pnrp_cloud_flags typedef enum _PNRP_CLOUD_FLAGS {
+ // PNRP_CLOUD_NO_FLAGS, PNRP_CLOUD_NAME_LOCAL, PNRP_CLOUD_RESOLVE_ONLY, PNRP_CLOUD_FULL_PARTICIPANT } PNRP_CLOUD_FLAGS;
+ [PInvokeData("pnrpdef.h", MSDNShortId = "NE:pnrpdef._PNRP_CLOUD_FLAGS")]
+ [Flags]
+ public enum PNRP_CLOUD_FLAGS
+ {
+ /// The cloud name is valid on the network.
+ PNRP_CLOUD_NO_FLAGS = 0x0,
+
+ /// The cloud name is not valid on other computers.
+ PNRP_CLOUD_NAME_LOCAL = 0x1,
+
+ /// The cloud is configured to be resolve only. Names cannot be published to the cloud from this computer.
+ PNRP_CLOUD_RESOLVE_ONLY = 0x2,
+
+ /// This machine is a full participant in the cloud, and can publish and resolve names.
+ PNRP_CLOUD_FULL_PARTICIPANT = 0x4,
+ }
+
+ /// The PNRP_CLOUD_STATE enumeration specifies the different states a PNRP cloud can be in.
+ // https://docs.microsoft.com/en-us/windows/win32/api/pnrpdef/ne-pnrpdef-pnrp_cloud_state typedef enum _PNRP_CLOUD_STATE {
+ // PNRP_CLOUD_STATE_VIRTUAL, PNRP_CLOUD_STATE_SYNCHRONISING, PNRP_CLOUD_STATE_ACTIVE, PNRP_CLOUD_STATE_DEAD,
+ // PNRP_CLOUD_STATE_DISABLED, PNRP_CLOUD_STATE_NO_NET, PNRP_CLOUD_STATE_ALONE } PNRP_CLOUD_STATE;
+ [PInvokeData("pnrpdef.h", MSDNShortId = "NE:pnrpdef._PNRP_CLOUD_STATE")]
+ public enum PNRP_CLOUD_STATE
+ {
+ /// The cloud is not yet initialized.
+ PNRP_CLOUD_STATE_VIRTUAL = 0,
+
+ /// The cloud is in the process of being initialized.
+ PNRP_CLOUD_STATE_SYNCHRONISING,
+
+ /// The cloud is active.
+ PNRP_CLOUD_STATE_ACTIVE,
+
+ /// The cloud is initialized, but has lost its connection to the network.
+ PNRP_CLOUD_STATE_DEAD,
+
+ /// The cloud is disabled in the registry.
+ PNRP_CLOUD_STATE_DISABLED,
+
+ ///
+ /// The cloud was active, but has lost access to the network. In this state the cloud can still be used for registration but it
+ /// is not capable of resolving addresses.
+ ///
+ PNRP_CLOUD_STATE_NO_NET,
+
+ ///
+ /// The local node bootstrapped, but found no other nodes in the cloud. This can also be the result of a network issue, like a
+ /// firewall, preventing the local node from locating other nodes within the cloud. It is also important to note that a cloud in
+ /// the PNRP_CLOUD_STATE_ALONE state may not have registered IP addresses.
+ ///
+ PNRP_CLOUD_STATE_ALONE,
+ }
+
+ ///
+ [PInvokeData("pnrpdef.h")]
+ public enum PNRP_EXTENDED_PAYLOAD_TYPE
+ {
+ ///
+ PNRP_EXTENDED_PAYLOAD_TYPE_NONE = 0,
+
+ ///
+ PNRP_EXTENDED_PAYLOAD_TYPE_BINARY,
+
+ ///
+ PNRP_EXTENDED_PAYLOAD_TYPE_STRING,
+ }
+
+ /// Registered name state.
+ [PInvokeData("pnrpdef.h")]
+ public enum PNRP_REGISTERED_ID_STATE
+ {
+ /// Id is active in cloud
+ PNRP_REGISTERED_ID_STATE_OK = 1,
+
+ /// Id is no longer registered in cloud
+ PNRP_REGISTERED_ID_STATE_PROBLEM = 2
+ }
+
+ /// The PNRP_RESOLVE_CRITERIA enumeration specifies the criteria that PNRP uses to resolve searches.
+ // https://docs.microsoft.com/en-us/windows/win32/api/pnrpdef/ne-pnrpdef-pnrp_resolve_criteria typedef enum _PNRP_RESOLVE_CRITERIA {
+ // PNRP_RESOLVE_CRITERIA_DEFAULT, PNRP_RESOLVE_CRITERIA_REMOTE_PEER_NAME, PNRP_RESOLVE_CRITERIA_NEAREST_REMOTE_PEER_NAME,
+ // PNRP_RESOLVE_CRITERIA_NON_CURRENT_PROCESS_PEER_NAME, PNRP_RESOLVE_CRITERIA_NEAREST_NON_CURRENT_PROCESS_PEER_NAME,
+ // PNRP_RESOLVE_CRITERIA_ANY_PEER_NAME, PNRP_RESOLVE_CRITERIA_NEAREST_PEER_NAME } PNRP_RESOLVE_CRITERIA;
+ [PInvokeData("pnrpdef.h", MSDNShortId = "NE:pnrpdef._PNRP_RESOLVE_CRITERIA")]
+ public enum PNRP_RESOLVE_CRITERIA
+ {
+ ///
+ /// Use the PNRP_RESOLVE_CRITERIA_NON_CURRENT_PROCESS_PEER_NAME criteria. This is also the default behavior if PNRPINFO is not specified.
+ ///
+ PNRP_RESOLVE_CRITERIA_DEFAULT = 0,
+
+ /// Match a peer name. The resolve request excludes any peer name registered locally on this computer.
+ PNRP_RESOLVE_CRITERIA_REMOTE_PEER_NAME,
+
+ ///
+ /// Match a peer name by finding the name with a service location closest to the supplied hint, or if no hint is supplied,
+ /// closest to the local IP address. The resolve request excludes any peer name registered locally on this computer.
+ ///
+ PNRP_RESOLVE_CRITERIA_NEAREST_REMOTE_PEER_NAME,
+
+ ///
+ /// Match a peer name. The matching peer name can be registered locally or remotely, but the resolve request excludes any peer
+ /// name registered by the process making the resolve request.
+ ///
+ PNRP_RESOLVE_CRITERIA_NON_CURRENT_PROCESS_PEER_NAME,
+
+ ///
+ /// Match a peer name by finding the name with a service location closest to the supplied hint, or if no hint is supplied,
+ /// closest to the local IP address. The matching peer name can be registered locally or remotely, but the resolve request
+ /// excludes any peer name registered by the process making the resolve request.
+ ///
+ PNRP_RESOLVE_CRITERIA_NEAREST_NON_CURRENT_PROCESS_PEER_NAME,
+
+ /// Match a peer name. The matching peer name can be registered locally or remotely.
+ PNRP_RESOLVE_CRITERIA_ANY_PEER_NAME,
+
+ ///
+ /// Match a peer name by finding the name with a service location closest to the supplied hint, or if no hint is supplied,
+ /// closest to the local IP address. The matching peer name can be registered locally or remotely.
+ ///
+ PNRP_RESOLVE_CRITERIA_NEAREST_PEER_NAME,
+ }
+
+ /// Specifies the scope under which the peer group was registered.
+ [PInvokeData("pnrpdef.h")]
+ public enum PNRP_SCOPE
+ {
+ /// Any scope.
+ PNRP_SCOPE_ANY = 0, // Any
+
+ /// Global scope, including the Internet.
+ PNRP_GLOBAL_SCOPE = 1, // global
+
+ /// Local scope.
+ PNRP_SITE_LOCAL_SCOPE = 2, // site local
+
+ /// Link-local scope.
+ PNRP_LINK_LOCAL_SCOPE = 3 // link local
+ }
+
+ /// Provides a handle to a Peer Graph.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HGRAPH : IHandle
+ {
+ private IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public HGRAPH(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static HGRAPH NULL => new HGRAPH(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(HGRAPH h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator HGRAPH(IntPtr h) => new HGRAPH(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(HGRAPH h1, HGRAPH h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(HGRAPH h1, HGRAPH h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is HGRAPH h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// The PEER_ADDRESS structure specifies the information about the IP address.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_address typedef struct peer_address_tag { DWORD dwSize;
+ // SOCKADDR_IN6 sin6; } PEER_ADDRESS, *PEER_ADDRESS*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_address_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_ADDRESS
+ {
+ /// Specifies the size of this structure.
+ public uint dwSize;
+
+ /// Specifies the IP address of the node in the Peer Infrastructure.
+ public SOCKADDR_IN6 sin6;
+ }
+
+ ///
+ /// The PEER_APP_LAUNCH_INFO structure contains the peer application application launch information provided by a contact in
+ /// a previous peer invite request.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_app_launch_info typedef struct peer_app_launch_info_tag {
+ // PEER_CONTACT* pContact; PEER_ENDPOINT* pEndpoint; PEER_INVITATION* pInvitation; } PEER_APP_LAUNCH_INFO, *PEER_APP_LAUNCH_INFO*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_app_launch_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_APP_LAUNCH_INFO
+ {
+ ///
+ /// Pointer to a PEER_CONTACT structure that contains information about the contact that sent the request to the local peer to
+ /// launch the application referenced by the application.
+ ///
+ public IntPtr pContact;
+
+ ///
+ /// Pointer to a PEER_ENDPOINT structure that contains information about the specific endpoint of the contact that sent the
+ /// request to the local peer to launch the application referenced by the application
+ ///
+ public IntPtr pEndpoint;
+
+ ///
+ /// Pointer to the PEER_INVITATION structure that contains the invitation to launch a specific peer application application on
+ /// the local peer.
+ ///
+ public IntPtr pInvitation;
+ }
+
+ ///
+ /// The PEER_APPLICATION structure contains data describing a locally installed software application or component that can be
+ /// registered and shared with trusted contacts within a peer collaboration network.
+ ///
+ ///
+ ///
+ /// 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 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 deregister a peer application, call PeerCollabUnregisterApplication with this GUID.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_application typedef struct peer_application_tag { GUID id;
+ // PEER_DATA data; PWSTR pwzDescription; } PEER_APPLICATION, *PEER_APPLICATION*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_application_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_APPLICATION
+ {
+ /// The GUID value under which the application is registered with the local computer.
+ public Guid id;
+
+ ///
+ /// PEER_DATA structure that contains the application information in a member byte buffer. This information is available to
+ /// anyone who can query for the local peer's member information. This data is limited to 16K.
+ ///
+ public PEER_DATA data;
+
+ ///
+ /// Pointer to a zero-terminated Unicode string that contains an optional description of the local application. This description
+ /// is limited to 255 unicode characters.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzDescription;
+ }
+
+ ///
+ /// The PEER_APPLICATION_REGISTRATION_INFO structure contains peer application information for registration with the local computer.
+ ///
+ ///
+ ///
+ /// An "application" is a set of software or software components 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 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 deregister a peer's application, call PeerCollabUnregisterApplication with this GUID.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_application_registration_info typedef struct
+ // peer_application_registration_info_tag { PEER_APPLICATION application; PWSTR pwzApplicationToLaunch; PWSTR
+ // pwzApplicationArguments; DWORD dwPublicationScope; } PEER_APPLICATION_REGISTRATION_INFO, *PEER_APPLICATION_REGISTRATION_INFO*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_application_registration_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_APPLICATION_REGISTRATION_INFO
+ {
+ /// PEER_APPLICATION structure that contains the specific peer application data.
+ public PEER_APPLICATION application;
+
+ ///
+ /// Zero-terminated Unicode string that contains the local path to the executable peer application. Note that this data is for
+ /// local use only and that this structure is never transmitted remotely.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzApplicationToLaunch;
+
+ ///
+ /// Zero-terminated Unicode string that contains command-line arguments that must be supplied to the application when the
+ /// application is launched. This data is for local use only. The PEER_APPLICATION_REGISTRATION_INFO structure is never
+ /// transmitted remotely.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzApplicationArguments;
+
+ ///
+ /// PEER_PUBLICATION_SCOPE enumeration value that specifies the publication scope for this application registration information.
+ /// The only valid value for this member is PEER_PUBLICATION_SCOPE_INTERNET.
+ ///
+ public PEER_PUBLICATION_SCOPE dwPublicationScope;
+ }
+
+ ///
+ /// The PEER_COLLAB_EVENT_DATA union contains variant data for each possible peer collaboration network event raised on a peer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_collab_event_data-r1 typedef struct peer_collab_event_data_tag
+ // { PEER_COLLAB_EVENT_TYPE eventType; union { PEER_EVENT_WATCHLIST_CHANGED_DATA watchListChangedData;
+ // PEER_EVENT_PRESENCE_CHANGED_DATA presenceChangedData; PEER_EVENT_APPLICATION_CHANGED_DATA applicationChangedData;
+ // PEER_EVENT_OBJECT_CHANGED_DATA objectChangedData; PEER_EVENT_ENDPOINT_CHANGED_DATA endpointChangedData;
+ // PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA peopleNearMeChangedData; PEER_EVENT_REQUEST_STATUS_CHANGED_DATA requestStatusChangedData;
+ // }; } PEER_COLLAB_EVENT_DATA, *PEER_COLLAB_EVENT_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_collab_event_data_tag~r1")]
+ [StructLayout(LayoutKind.Explicit)]
+ public struct PEER_COLLAB_EVENT_DATA
+ {
+ ///
+ /// PEER_COLLAB_EVENT_TYPE enumeration value that contains the type of the event whose corresponding data structure appears in
+ /// the subsequent union arm.
+ ///
+ [FieldOffset(0)]
+ public PEER_COLLAB_EVENT_TYPE eventType;
+
+ ///
+ /// A PEER_EVENT_WATCHLIST_CHANGED_DATA structure. This data structure is present when eventType is set to PEER_EVENT_WATCHLIST_CHANGED.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_WATCHLIST_CHANGED_DATA watchListChangedData;
+
+ ///
+ /// A PEER_EVENT_PRESENCE_CHANGED_DATA structure. This data structure is present when eventType is set to
+ /// PEER_EVENT_ENDPOINT_PRESENCE_CHANGED or PEER_EVENT_MY_PRESENCE_CHANGED.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_PRESENCE_CHANGED_DATA presenceChangedData;
+
+ ///
+ /// A PEER_EVENT_APPLICATION_CHANGED_DATA structure. This data structure is present when eventType is set to
+ /// PEER_EVENT_ENDPOINT_APPLICATION_CHANGED or PEER_EVENT_MY_APPLICATION_CHANGED.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_APPLICATION_CHANGED_DATA applicationChangedData;
+
+ ///
+ /// A PEER_EVENT_OBJECT_CHANGED_DATA structure. This data structure is present when eventType is set to
+ /// PEER_EVENT_ENDPOINT_OBJECT_CHANGED or PEER_EVENT_MY_OBJECT_CHANGED.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_OBJECT_CHANGED_DATA objectChangedData;
+
+ ///
+ /// A PEER_EVENT_ENDPOINT_CHANGED_DATA structure. This data structure is present when eventType is set to
+ /// PEER_EVENT_ENDPOINT_CHANGED or PEER_EVENT_MY_ENDPOINT_CHANGED.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_ENDPOINT_CHANGED_DATA endpointChangedData;
+
+ ///
+ /// A PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA structure. This data structure is present when eventType is set to PEER_EVENT_PEOPLE_NEAR_ME_CHANGED.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA peopleNearMeChangedData;
+
+ ///
+ /// A PEER_EVENT_REQUEST_STATUS_CHANGED_DATA structure. This data structure is present when eventType is set to PEER_EVENT_REQUEST_STATUS_CHANGED.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_REQUEST_STATUS_CHANGED_DATA requestStatusChangedData;
+ }
+
+ ///
+ /// The PEER_COLLAB_EVENT_REGISTRATION structure contains the data used by a peer to register for specific peer collaboration
+ /// network events.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_collab_event_registration typedef struct
+ // peer_collab_event_registration_tag { PEER_COLLAB_EVENT_TYPE eventType; GUID *pInstance; } PEER_COLLAB_EVENT_REGISTRATION, *PEER_COLLAB_EVENT_REGISTRATION*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_collab_event_registration_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_COLLAB_EVENT_REGISTRATION
+ {
+ ///
+ /// PEER_COLLAB_EVENT_TYPE enumeration value that specifies the type of peer collaboration network event for which to register.
+ ///
+ public PEER_COLLAB_EVENT_TYPE eventType;
+
+ ///
+ /// GUID value that uniquely identifies the application or object that registers for the specific event.
+ ///
+ /// This parameter is valid only for PEER_EVENT_ENDPOINT_APPLICATION_CHANGED, PEER_EVENT_ENDPOINT_OBJECT_CHANGED,
+ /// PEER_EVENT_MY_APPLICATION_CHANGED, and PEER_EVENT_MY_OBJECT_CHANGED. This GUID represents the application ID for
+ /// application-specific events, and the object ID for object-specific events.
+ ///
+ /// When this member is set, notification will be sent only for the specific application or object.
+ ///
+ public IntPtr pInstance;
+ }
+
+ ///
+ /// The PEER_CONNECTION_INFO structure contains information about a connection. This structure is returned when you are
+ /// enumerating peer graphing or grouping connections.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_connection_info typedef struct peer_connection_info_tag {
+ // DWORD dwSize; DWORD dwFlags; ULONGLONG ullConnectionId; ULONGLONG ullNodeId; PWSTR pwzPeerId; PEER_ADDRESS address; } PEER_CONNECTION_INFO;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_connection_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_CONNECTION_INFO
+ {
+ /// Specifies the size a structure.
+ public uint dwSize;
+
+ /// Specifies the type of connection to a remote node. Valid values are specified by PEER_CONNECTION_FLAGS.
+ public PEER_CONNECTION_FLAGS dwFlags;
+
+ /// Specifies the unique ID of a connection.
+ public ulong ullConnectionId;
+
+ /// Specifies the unique ID of a node.
+ public ulong ullNodeId;
+
+ /// Points to a string that identifies the node on the other end of a connection.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzPeerId;
+
+ /// Specifies the address of a remote node. The address is contained in a PEER_ADDRESS structure.
+ public PEER_ADDRESS address;
+ }
+
+ /// The PEER_CONTACT structure contains information about a specific contact.
+ ///
+ /// "Contacts" are peers participating in a peer collaboration network who publish presence information available to the local peer.
+ /// This associated information enables the peer application to "watch" them for updates and peer application or object status
+ /// changes. Lists of contacts are maintained by the peer collaboration infrastructure, and specific status change events are raised
+ /// for each individual contact in the list.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_contact typedef struct peer_contact_tag { PWSTR pwzPeerName;
+ // PWSTR pwzNickName; PWSTR pwzDisplayName; PWSTR pwzEmailAddress; BOOL fWatch; PEER_WATCH_PERMISSION WatcherPermissions; PEER_DATA
+ // credentials; } PEER_CONTACT, *PEER_CONTACT*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_contact_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_CONTACT
+ {
+ ///
+ /// Zero-terminated Unicode string that contains the peer name of the contact. This is the unique identifier for a contact.
+ /// There can only be a single contact associated with any given peername.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzPeerName;
+
+ ///
+ ///
+ /// Zero-terminated Unicode string that contains the nickname of the contact and can be modified at any time. This is used when
+ /// the peer collaboration scope is set to People Near Me. It is advertised in People Near Me and seen by recipients of sent invitations.
+ ///
+ /// This member is limited to 255 unicode characters.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzNickName;
+
+ ///
+ ///
+ /// Zero-terminated Unicode string that contains the display name of the contact. This corresponds to the display name seen for
+ /// the contact in a peer's contacts folder.
+ ///
+ /// This member is limited to 255 unicode characters.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzDisplayName;
+
+ /// Zero-terminated Unicode string that contains the email address of the contact.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzEmailAddress;
+
+ /// If true, the contact is watched by the peer; if false, it is not.
+ [MarshalAs(UnmanagedType.Bool)]
+ public bool fWatch;
+
+ /// PEER_WATCH_PERMISSION enumeration value that specifies the watch permissions for this contact.
+ public PEER_WATCH_PERMISSION WatcherPermissions;
+
+ /// PEER_DATA structure that contains the security credentials for the contact in an opaque byte buffer.
+ public PEER_DATA credentials;
+ }
+
+ /// The PEER_CREDENTIAL_INFO structure defines information used to obtain and issue a peer's security credentials.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_credential_info typedef struct peer_credential_info_tag {
+ // DWORD dwSize; DWORD dwFlags; PWSTR pwzFriendlyName; CERT_PUBLIC_KEY_INFO *pPublicKey; PWSTR pwzIssuerPeerName; PWSTR
+ // pwzIssuerFriendlyName; FILETIME ftValidityStart; FILETIME ftValidityEnd; ULONG cRoles; PEER_ROLE_ID *pRoles; }
+ // PEER_CREDENTIAL_INFO, *PEER_CREDENTIAL_INFO*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_credential_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_CREDENTIAL_INFO
+ {
+ /// Specifies the size of this structure, in bytes.
+ public uint dwSize;
+
+ /// Reserved. This field must be set to 0.
+ public uint dwFlags;
+
+ /// Pointer to a Unicode string that specifies the friendly (display) name of the issuer.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzFriendlyName;
+
+ ///
+ /// Pointer to a CERT_PUBLIC_KEY_INFO structure that contains the peer group member's public key and the encryption type
+ /// it uses.
+ ///
+ public IntPtr pPublicKey;
+
+ /// Pointer to a Unicode string that specifies the membership issuer's PNRP name.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzIssuerPeerName;
+
+ /// Pointer to a Unicode string that specifies the friendly (display) name of the issuer.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzIssuerFriendlyName;
+
+ ///
+ /// Specifies the FILETIME structure that contains the time when the recipient's membership in the peer group becomes valid.
+ /// When issuing new credentials this value must be greater than the ValidityStart value for the member's current credentials.
+ ///
+ public FILETIME ftValidityStart;
+
+ ///
+ /// Specifies the FILETIME structure that contains the time when the recipient's membership in the peer group becomes invalid.
+ ///
+ public FILETIME ftValidityEnd;
+
+ /// Specifies the number of role GUIDs present in pRoles.
+ public uint cRoles;
+
+ ///
+ /// Pointer to a list of GUIDs that specifies the combined set of available roles. The available roles are as follows.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_GROUP_ROLE_ADMIN
+ ///
+ /// This role can issue invitations, issue credentials, and renew the GMC of other administrators, as well as behave as a member
+ /// of the peer group.
+ ///
+ ///
+ /// -
+ /// PEER_GROUP_ROLE_MEMBER
+ /// The role can add records to the peer group database.
+ ///
+ ///
+ ///
+ public IntPtr pRoles;
+ }
+
+ /// The PEER_DATA structure contains binary data.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_data typedef struct peer_data_tag { ULONG cbData; PBYTE
+ // pbData; } PEER_DATA, *PEER_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_DATA
+ {
+ ///
+ /// Size of pbData, in bytes. It is possible for this value to be set to zero if pbData contains no data.
+ ///
+ public uint cbData;
+
+ /// Pointer to a buffer.
+ public IntPtr pbData;
+ }
+
+ /// The PEER_ENDPOINT structure contains the address and friendly name of a peer endpoint.
+ ///
+ ///
+ /// A peer "endpoint" describes a contact's presence location — the unique network address configuration that describes the
+ /// currently available instance of the contact within the peer collaboration network. A single contact can be available at multiple
+ /// endpoints within the peer collaboration network.
+ ///
+ ///
+ /// A peer watching a contact can query any of the endpoints associated with that contact for specific peer presence, application,
+ /// or object updates.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_endpoint typedef struct peer_endpoint_tag { PEER_ADDRESS
+ // address; PWSTR pwzEndpointName; } PEER_ENDPOINT, *PEER_ENDPOINT*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_endpoint_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_ENDPOINT
+ {
+ /// PEER_ADDRESS structure that contains the IPv6 network address of the endpoint.
+ public PEER_ADDRESS address;
+
+ /// Zero-terminated Unicode string that contains the specific displayable name of the endpoint.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzEndpointName;
+ }
+
+ ///
+ /// The PEER_EVENT_APPLICATION_CHANGED_DATA structure contains information returned when a
+ /// PEER_EVENT_ENDPOINT_APPLICATION_CHANGED or PEER_EVENT_MY_APPLICATION_CHANGED event is raised on a peer participating in a peer
+ /// collaboration network.
+ ///
+ ///
+ ///
+ /// "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 deregister a peer's application, call PeerCollabUnregisterApplication with this GUID.
+ ///
+ ///
+ /// When a new application is registered locally using PeerCollabRegisterApplication or unregistered using
+ /// PeerCollabUnregisterApplication all peers subscribed to the local peer's presence information receive the
+ /// PEER_EVENT_ENDPOINT_APPLICATION_CHANGED event. Locally, applications receive the PEER_EVENT_MY_APPLICATION_CHANGED event.
+ ///
+ ///
+ /// The current user scope has priority over the all user scope. If the application is registered in both scopes, the
+ /// event will be fired only if the current user scope is changed.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_application_changed_data typedef struct
+ // peer_event_application_changed_data_tag { PEER_CONTACT* pContact; PEER_ENDPOINT* pEndpoint; PEER_CHANGE_TYPE changeType;
+ // PEER_APPLICATION* pApplication; } PEER_EVENT_APPLICATION_CHANGED_DATA, *PEER_EVENT_APPLICATION_CHANGED_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_application_changed_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_APPLICATION_CHANGED_DATA
+ {
+ ///
+ /// Pointer to a PEER_CONTACT structure that contains the peer contact information for a contact whose change in application
+ /// raised the event.
+ ///
+ public IntPtr pContact;
+
+ ///
+ /// Pointer to a PEER_ENDPOINT structure that contains the peer endpoint information for a contact whose change in application
+ /// information raised the event.
+ ///
+ public IntPtr pEndpoint;
+
+ /// PEER_CHANGE_TYPE enumeration value that specifies the type of application change that occurred.
+ public PEER_CHANGE_TYPE changeType;
+
+ /// Pointer to a PEER_APPLICATION structure that contains the changed application information.
+ public IntPtr pApplication;
+ }
+
+ ///
+ ///
+ /// A PEER_GRAPH_EVENT_DATA structure points to the PEER_EVENT_CONNECTION_CHANGE_DATA structure if one of the following peer
+ /// events is triggered:
+ ///
+ ///
+ /// -
+ /// PEER_GRAPH_EVENT_NEIGHBOR_CONNECTION
+ ///
+ /// -
+ /// PEER_GRAPH_EVENT_DIRECT_CONNECTION
+ ///
+ /// -
+ /// PEER_GROUP_EVENT_NEIGHBOR_CONNECTION
+ ///
+ /// -
+ /// PEER_GROUP_EVENT_DIRECT_CONNECTION
+ ///
+ ///
+ ///
+ /// The PEER_EVENT_CONNECTION_CHANGE_DATA structure contains updated information that includes changes to a neighbor or
+ /// direct connection.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_connection_change_data typedef struct
+ // peer_event_connection_change_data_tag { DWORD dwSize; PEER_CONNECTION_STATUS status; ULONGLONG ullConnectionId; ULONGLONG
+ // ullNodeId; ULONGLONG ullNextConnectionId; HRESULT hrConnectionFailedReason; } PEER_EVENT_CONNECTION_CHANGE_DATA, *PEER_EVENT_CONNECTION_CHANGE_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_connection_change_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_CONNECTION_CHANGE_DATA
+ {
+ /// Specifies the size of a structure.
+ public uint dwSize;
+
+ ///
+ /// Specifies the type of change in a neighbor or direct connection. Valid values are the following.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_CONNECTED
+ /// A new incoming or outgoing connection to the local node has been established.
+ ///
+ /// -
+ /// PEER_CONNECTION_FAILED
+ ///
+ /// An attempt to connect to a local node has failed. It is possible for a single attempt to connect to result in multiple
+ /// connection failures. This will occur after the initial connection failure, when the peer infrastructure sets the
+ /// ullNextConnectionId member to the Node ID and attempts a new connection. If the ullNextConnectionId member is 0, no further
+ /// connections will be attempted.
+ ///
+ ///
+ /// -
+ /// PEER_DISCONNECTED
+ /// An existing connection has been disconnected.
+ ///
+ ///
+ ///
+ public PEER_CONNECTION_STATUS status;
+
+ /// Specifies the unique ID for a connection that has changed.
+ public ulong ullConnectionId;
+
+ /// Specifies the unique ID for the node that has changed.
+ public ulong ullNodeId;
+
+ ///
+ public ulong ullNextConnectionId;
+
+ ///
+ ///
+ /// Windows Vista or later. Specifies the type of error when a connection fails. hrConnectionFailedReason can
+ /// return the following error codes.
+ ///
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// PEER_E_CONNECTION_REFUSED
+ ///
+ /// A connection has been established and refused. The remote node is already at maximum number of connections or a connection
+ /// already exists.
+ ///
+ ///
+ /// -
+ /// PEER_E_CONNECTION_FAILED
+ /// An attempt to connect to a remote node has failed.
+ ///
+ /// -
+ /// PEER_E_CONNECTION_NOT_AUTHENTICATED
+ ///
+ /// A connection is lost during the authentication phase. This is the result of a network failure or the remote node breaking
+ /// the connection.
+ ///
+ ///
+ ///
+ ///
+ public HRESULT hrConnectionFailedReason;
+ }
+
+ ///
+ /// The PEER_EVENT_ENDPOINT_CHANGED_DATA structure contains information returned when a PEER_EVENT_ENDPOINT_CHANGED or
+ /// PEER_EVENT_MY_ENDPOINT_CHANGED event is raised on a peer participating in a peer collaboration network.
+ ///
+ ///
+ /// This event is raised when information about the endpoint changes. An example of this being the endpoint name in PEER_ENDPOINT
+ /// structure is changed using PeerCollabSetEndpointName.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_endpoint_changed_data typedef struct
+ // peer_event_endpoint_changed_data_tag { PEER_CONTACT* pContact; PEER_ENDPOINT* pEndpoint; } PEER_EVENT_ENDPOINT_CHANGED_DATA, *PEER_EVENT_ENDPOINT_CHANGED_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_endpoint_changed_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_ENDPOINT_CHANGED_DATA
+ {
+ /// Pointer to a PEER_CONTACT structure that contains the contact information for the contact who changed endpoints.
+ public IntPtr pContact;
+
+ /// Pointer to a PEER_ENDPOINT structure that contains the new active endpoint for the peer specified in pContact.
+ public IntPtr pEndpoint;
+ }
+
+ ///
+ ///
+ /// The PEER_GROUP_EVENT_DATA structure points to the PEER_EVENT_INCOMING_DATA structure if one of the following peer events
+ /// is triggered:
+ ///
+ ///
+ /// -
+ /// PEER_GRAPH_INCOMING_DATA
+ ///
+ /// -
+ /// PEER_GROUP_INCOMING_DATA
+ ///
+ ///
+ ///
+ /// The PEER_EVENT_INCOMING_DATA structure contains updated information that includes data changes a node receives from a
+ /// neighbor or direct connection.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_incoming_data typedef struct
+ // peer_event_incoming_data_tag { DWORD dwSize; ULONGLONG ullConnectionId; GUID type; PEER_DATA data; } PEER_EVENT_INCOMING_DATA, *PEER_EVENT_INCOMING_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_incoming_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_INCOMING_DATA
+ {
+ /// Specifies the size of a structure.
+ public uint dwSize;
+
+ /// Specifies the unique ID of a data connection.
+ public ulong ullConnectionId;
+
+ /// Specifies the application-defined data type of incoming data.
+ public Guid type;
+
+ /// Specifies the actual data received.
+ public PEER_DATA data;
+ }
+
+ ///
+ /// The PEER_EVENT_MEMBER_CHANGE_DATA structure contains data that describes a change in the status of a peer group member.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_member_change_data typedef struct
+ // peer_event_member_change_data_tag { DWORD dwSize; PEER_MEMBER_CHANGE_TYPE changeType; PWSTR pwzIdentity; }
+ // PEER_EVENT_MEMBER_CHANGE_DATA, *PEER_EVENT_MEMBER_CHANGE_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_member_change_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_MEMBER_CHANGE_DATA
+ {
+ /// Contains the size of this structure, in bytes.
+ public uint dwSize;
+
+ ///
+ /// PEER_MEMBER_CHANGE_TYPE enumeration value that specifies the change event that occurred, such as a member joining or leaving.
+ ///
+ public PEER_MEMBER_CHANGE_TYPE changeType;
+
+ /// Pointer to a Unicode string that contains the peer name of the peer group member.
+ public StrPtrUni pwzIdentity;
+ }
+
+ ///
+ /// The PEER_EVENT_NODE_CHANGE_DATA structure contains a pointer to the data if a PEER_GRAPH_EVENT_NODE_CHANGE event
+ /// is triggered.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_node_change_data typedef struct
+ // peer_event_node_change_data_tag { DWORD dwSize; PEER_NODE_CHANGE_TYPE changeType; ULONGLONG ullNodeId; PWSTR pwzPeerId; }
+ // PEER_EVENT_NODE_CHANGE_DATA, *PEER_EVENT_NODE_CHANGE_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_node_change_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_NODE_CHANGE_DATA
+ {
+ /// Specifies the size of the structure. Should set to the size of PEER_EVENT_NODE_CHANGE_DATA.
+ public uint dwSize;
+
+ ///
+ /// Specifies the new state of the node. Valid values are the following.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_NODE_CHANGE_CONNECTED
+ /// The node is present in the graph.
+ ///
+ /// -
+ /// PEER_NODE_CHANGE_DISCONNECTED
+ /// The node is no longer present in the graph.
+ ///
+ /// -
+ /// PEER_NODE_CHANGE_UPDATED
+ /// The node has new information, for example, the attributes have changed.
+ ///
+ ///
+ ///
+ public PEER_NODE_CHANGE_TYPE changeType;
+
+ /// Specifies the unique ID of the node that has changed.
+ public ulong ullNodeId;
+
+ /// Specifies the peer ID of the node that has changed.
+ public StrPtrUni pwzPeerId;
+ }
+
+ ///
+ /// The PEER_EVENT_OBJECT_CHANGED_DATA structure contains information returned when a PEER_EVENT_ENDPOINT_OBJECT_CHANGED or
+ /// PEER_EVENT_MY_OBJECT_CHANGED event is raised on a peer participating in a peer collaboration network.
+ ///
+ ///
+ ///
+ /// Peer objects are run-time data items associated with a particular application, such as a picture or avatar, a certificate, or a
+ /// specific description. Each peer object must be smaller than 16K in size.
+ ///
+ ///
+ /// Trusted contacts watching this peer object will have a PEER_EVENT_OBJECT_CHANGED event raised on them signaling the peer
+ /// object's change in status.
+ ///
+ ///
+ /// The PEER_EVENT_OBJECT_CHANGED event is raised when an object is changed by calling PeerCollabSetObject. If it is the first time
+ /// the object is set then changeType is set to PEER_CHANGE_ADDED. On subsequent calls of PeerCollabSetObject for the same
+ /// object ID the changeType is set to PEER_CHANGE_UDPATED.
+ ///
+ /// If PeerCollabDeleteObject is called the PEER_CHANGE_DELETED event is raised.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_object_changed_data typedef struct
+ // peer_event_object_changed_data_tag { PEER_CONTACT* pContact; PEER_ENDPOINT* pEndpoint; PEER_CHANGE_TYPE changeType; PEER_OBJECT*
+ // pObject; } PEER_EVENT_OBJECT_CHANGED_DATA, *PEER_EVENT_OBJECT_CHANGED_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_object_changed_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_OBJECT_CHANGED_DATA
+ {
+ ///
+ /// Pointer to a PEER_CONTACT structure that contains the peer contact information for the contact whose peer object data changed.
+ ///
+ public IntPtr pContact;
+
+ ///
+ /// Pointer to a PEER_ENDPOINT structure that contains the peer endpoint information for the contact whose peer object data changed.
+ ///
+ public IntPtr pEndpoint;
+
+ /// PEER_CHANGE_TYPE enumeration value that specifies the type of change that occurred.
+ public PEER_CHANGE_TYPE changeType;
+
+ ///
+ /// Pointer to a PEER_OBJECT structure that contains the peer object data whose change raised the event. This most commonly
+ /// occurs when a new peer object is received by the peer.
+ ///
+ public IntPtr pObject;
+ }
+
+ ///
+ /// The PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA structure contains information returned when a
+ /// PEER_EVENT_PEOPLE_NEAR_ME_CHANGED event is raised on a peer participating in a subnet-specific peer collaboration network.
+ ///
+ ///
+ /// The information that can be changed in a peer contact include the endpoint's name or its associated IPv6 address.
+ ///
+ /// If the changeType is set to PEER_CHANGE_ADDED and pEndpoint is set to NULL, then the local peer has signed
+ /// in. Otherwise, if changeType is set to PEER_CHANGE_DELETEDimplies the local peer has signed out.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_people_near_me_changed_data typedef struct
+ // peer_event_people_near_me_changed_data_tag { PEER_CHANGE_TYPE changeType; PEER_PEOPLE_NEAR_ME* pPeopleNearMe; }
+ // PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA, *PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_people_near_me_changed_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA
+ {
+ ///
+ /// PEER_CHANGE_TYPE enumeration value that describes the type of change that occurred for a contact available on the local subnet.
+ ///
+ public PEER_CHANGE_TYPE changeType;
+
+ ///
+ /// Pointer to a PEER_PEOPLE_NEAR_ME structure that contains the peer endpoint information for the contact on the subnet that
+ /// raised the change event.
+ ///
+ public IntPtr pPeopleNearMe;
+ }
+
+ ///
+ /// The PEER_EVENT_PRESENCE_CHANGED_DATA structure contains information returned when a PEER_EVENT_ENDPOINT_PRESENCE_CHANGED
+ /// or PEER_EVENT_MY_PRESENCE_CHANGED event is raised on a peer participating in a peer collaboration network.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_presence_changed_data typedef struct
+ // peer_event_presence_changed_data_tag { PEER_CONTACT* pContact; PEER_ENDPOINT* pEndpoint; PEER_CHANGE_TYPE changeType;
+ // PEER_PRESENCE_INFO* pPresenceInfo; } PEER_EVENT_PRESENCE_CHANGED_DATA, *PEER_EVENT_PRESENCE_CHANGED_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_presence_changed_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_PRESENCE_CHANGED_DATA
+ {
+ ///
+ /// Pointer to a PEER_CONTACT structure that contains the peer contact information for the contact whose change in presence
+ /// raised the event.
+ ///
+ public IntPtr pContact;
+
+ ///
+ /// Pointer to a PEER_ENDPOINT structure that contains the peer endpoint information for the contact whose change in presence
+ /// raised the event.
+ ///
+ public IntPtr pEndpoint;
+
+ /// PEER_CHANGE_TYPE enumeration value that specifies the type of presence change that occurred.
+ public PEER_CHANGE_TYPE changeType;
+
+ ///
+ /// Pointer to a PEER_PRESENCE_INFO structure that contains the updated presence information for the endpoint of the contact
+ /// whose change in presence raised the event.
+ ///
+ public IntPtr pPresenceInfo;
+ }
+
+ ///
+ ///
+ /// The PEER_GROUP_EVENT_DATA structure points to the PEER_EVENT_RECORD_CHANGE_DATA structure if one of the following peer
+ /// events is triggered:
+ ///
+ ///
+ /// -
+ /// PEER_GRAPH_EVENT_RECORD_CHANGE
+ ///
+ /// -
+ /// PEER_GROUP_EVENT_RECORD_CHANGE
+ ///
+ ///
+ ///
+ /// The PEER_EVENT_RECORD_CHANGE_DATA structure contains updated information that an application requests for data changes to
+ /// a record or record type.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_record_change_data typedef struct
+ // peer_event_record_change_data_tag { DWORD dwSize; PEER_RECORD_CHANGE_TYPE changeType; GUID recordId; GUID recordType; }
+ // PEER_EVENT_RECORD_CHANGE_DATA, *PEER_EVENT_RECORD_CHANGE_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_record_change_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_RECORD_CHANGE_DATA
+ {
+ /// Specifies the size of a structure.
+ public uint dwSize;
+
+ /// Specifies the type of change to a record or record type.
+ public PEER_RECORD_CHANGE_TYPE changeType;
+
+ /// Specifies the unique ID of a changed record.
+ public Guid recordId;
+
+ /// Specifies the unique record type of a changed record.
+ public Guid recordType;
+ }
+
+ ///
+ /// The PEER_EVENT_REQUEST_STATUS_CHANGED_DATA structure contains information returned when a
+ /// PEER_EVENT_REQUEST_STATUS_CHANGED event is raised on a peer participating in a peer collaboration network.
+ ///
+ ///
+ /// This event is raised when the infrastructure finishes processing the request for PeerCollabRefreshEndpointData or
+ /// PeerCollabSubscribeEndpointData. If the process fails hrChange value will most typically be PEER_E_CONNECTION_FAILED.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_request_status_changed_data typedef struct
+ // peer_event_request_status_changed_data_tag { PEER_ENDPOINT* pEndpoint; HRESULT hrChange; }
+ // PEER_EVENT_REQUEST_STATUS_CHANGED_DATA, *PEER_EVENT_REQUEST_STATUS_CHANGED_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_request_status_changed_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_REQUEST_STATUS_CHANGED_DATA
+ {
+ ///
+ /// Pointer to a PEER_ENDPOINT structure that contains the peer endpoint information for the contact whose change in request
+ /// status raised the event.
+ ///
+ public IntPtr pEndpoint;
+
+ /// HRESULT value that indicates the change in request status that occurred.
+ public HRESULT hrChange;
+ }
+
+ ///
+ /// The PEER_EVENT_SYNCHRONIZED_DATA is pointed to by a PEER_GRAPH_EVENT_DATA structure's union if a
+ /// PEER_GRAPH_EVENT_RECORD_CHANGE or PEER_GROUP_EVENT_RECORD_CHANGE event is triggered. The PEER_EVENT_SYNCHRONIZED_DATA
+ /// structure indicates the type of record that has been synchronized.
+ ///
+ ///
+ /// This event only occurs if an application has specified a record synchronization precedence in a previous call to PeerGraphOpen.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_synchronized_data typedef struct
+ // peer_event_synchronized_data_tag { DWORD dwSize; GUID recordType; } PEER_EVENT_SYNCHRONIZED_DATA, *PEER_EVENT_SYNCHRONIZED_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_synchronized_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_SYNCHRONIZED_DATA
+ {
+ /// Specifies the size of the structure.
+ public uint dwSize;
+
+ /// Specifies the type of record that is being synchronized.
+ public Guid recordType;
+ }
+
+ ///
+ /// The PEER_EVENT_WATCHLIST_CHANGED_DATA structure contains information returned when a PEER_EVENT_WATCHLIST_CHANGED event
+ /// is raised on a peer participating in a peer collaboration network.
+ ///
+ ///
+ ///
+ /// The PEER_EVENT_WATCHLIST_CHANGED event is raised when the watch list is changed. The watch list is composed of the contacts that
+ /// have fWatch set to true. If a new contact is added with fWatch set to true, or if an existing contact's
+ /// fWatch is changed to true, the changeType member is set to PEER_CHANGE_ADDED. If fWatch is changed to false
+ /// or if a contact is deleted, changeType is set to PEER_CHANGE_DELETED.
+ ///
+ ///
+ /// The p2phost.exe service must running to receive this event. P2phost.exe is launched when an application calls
+ /// PeerCollabRegisterEvent on this event.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_event_watchlist_changed_data typedef struct
+ // peer_event_watchlist_changed_data_tag { PEER_CONTACT* pContact; PEER_CHANGE_TYPE changeType; } PEER_EVENT_WATCHLIST_CHANGED_DATA, *PEER_EVENT_WATCHLIST_CHANGED_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_event_watchlist_changed_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_EVENT_WATCHLIST_CHANGED_DATA
+ {
+ ///
+ /// Pointer to a PEER_CONTACT structure that contains information about the peer contact in the watchlist whose change raised
+ /// the event.
+ ///
+ public IntPtr pContact;
+
+ /// PEER_CHANGE_TYPE enumeration value that specifies the type of change that occurred in the peer's watchlist.
+ public PEER_CHANGE_TYPE changeType;
+ }
+
+ /// The PEER_GRAPH_EVENT_DATA structure contains data associated with a peer event.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_graph_event_data typedef struct peer_graph_event_data_tag {
+ // PEER_GRAPH_EVENT_TYPE eventType; union { PEER_GRAPH_STATUS_FLAGS dwStatus; PEER_EVENT_INCOMING_DATA incomingData;
+ // PEER_EVENT_RECORD_CHANGE_DATA recordChangeData; PEER_EVENT_CONNECTION_CHANGE_DATA connectionChangeData;
+ // PEER_EVENT_NODE_CHANGE_DATA nodeChangeData; PEER_EVENT_SYNCHRONIZED_DATA synchronizedData; }; } PEER_GRAPH_EVENT_DATA, *PEER_GRAPH_EVENT_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_graph_event_data_tag")]
+ [StructLayout(LayoutKind.Explicit)]
+ public struct PEER_GRAPH_EVENT_DATA
+ {
+ ///
+ /// The type of peer event this data corresponds to. Must be one of the PEER_GRAPH_EVENT_TYPE values. The members that remain
+ /// are given values based on the peer event type that has occurred. Not all members contain data.
+ ///
+ [FieldOffset(0)]
+ public PEER_GRAPH_EVENT_TYPE eventType;
+
+ ///
+ /// This member is given a value if the PEER_GRAPH_EVENT_STATUS_CHANGE peer event is triggered. A change has been made in
+ /// relation to a node's connection to the graph.
+ ///
+ [FieldOffset(4)]
+ public PEER_GRAPH_STATUS_FLAGS dwStatus;
+
+ ///
+ /// This member is given a value if the PEER_GRAPH_INCOMING_DATA peer event is triggered. A node has received data from a
+ /// neighbor or a direct connection.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_INCOMING_DATA incomingData;
+
+ ///
+ /// This member given a value if the PEER_GRAPH_EVENT_RECORD_CHANGE peer event is triggered. A record type the application asked
+ /// for notifications of has changed.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_RECORD_CHANGE_DATA recordChangeData;
+
+ ///
+ /// This member is given a value if the PEER_GRAPH_EVENT_NEIGHBOR_CONNECTION or PEER_GRAPH_EVENT_DIRECT_CONNECTION peer
+ /// event is triggered. An aspect of a neighbor or direct connection state has changed.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_CONNECTION_CHANGE_DATA connectionChangeData;
+
+ ///
+ /// This member is given a value if the PEER_GRAPH_EVENT_NODE_CHANGED peer event is triggered. A node's presence state has changed.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_NODE_CHANGE_DATA nodeChangeData;
+
+ ///
+ /// This member is given a value if the PEER_GRAPH_EVENT_SYNCHRONIZED peer event is triggered. A record type has completed its synchronization.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_SYNCHRONIZED_DATA synchronizedData;
+ }
+
+ ///
+ /// The PEER_GRAPH_EVENT_REGISTRATION structure is used during registration for peer event notification. During registration
+ /// it specifies which peer events an application requires notifications for.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_graph_event_registration typedef struct
+ // peer_graph_event_registration_tag { PEER_GRAPH_EVENT_TYPE eventType; GUID *pType; } PEER_GRAPH_EVENT_REGISTRATION, *PEER_GRAPH_EVENT_REGISTRATION*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_graph_event_registration_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_GRAPH_EVENT_REGISTRATION
+ {
+ ///
+ /// Specifies the type of peer event the application requires notifications for. The per events that can be registered for are
+ /// specified by the PEER_GRAPH_EVENT_TYPE enumeration.
+ ///
+ public PEER_GRAPH_EVENT_TYPE eventType;
+
+ ///
+ /// If the peer event specified by eventType relates to records, use this member to specify which types of records the
+ /// application requires notifications for. Specify NULL to receive notifications for all record types. This member is
+ /// ignored if the event specified by eventType does not relate to records.
+ ///
+ public IntPtr pType;
+ }
+
+ ///
+ /// The PEER_GRAPH_PROPERTIES structure contains data about the policy of a peer graph, ID, scope, and other information.
+ ///
+ ///
+ /// An application can force the Peer Graphing Infrastructure to publish presence information by using PeerGraphSetPresence.
+ ///
+ /// Only specific fields in the PEER_GRAPH_PROPERTIES can be updated when calling PeerGraphSetProperties. The following
+ /// members can be updated:
+ ///
+ ///
+ /// -
+ /// pwzFriendlyName
+ ///
+ /// -
+ /// pwzComment
+ ///
+ /// -
+ /// ulPresenceLifetime
+ ///
+ /// -
+ /// cPresenceMax
+ ///
+ ///
+ /// The remaining members cannot be modified.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_graph_properties typedef struct peer_graph_properties_tag {
+ // DWORD dwSize; DWORD dwFlags; DWORD dwScope; DWORD dwMaxRecordSize; PWSTR pwzGraphId; PWSTR pwzCreatorId; PWSTR pwzFriendlyName;
+ // PWSTR pwzComment; ULONG ulPresenceLifetime; ULONG cPresenceMax; } PEER_GRAPH_PROPERTIES, *PEER_GRAPH_PROPERTIES*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_graph_properties_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_GRAPH_PROPERTIES
+ {
+ ///
+ /// Specifies the size, in bytes, of this data structure. The dwSize member must be set to the size of
+ /// PEER_GRAPH_PROPERTIES before calling PeerGraphCreate. This member is required. There is not a default value.
+ ///
+ public uint dwSize;
+
+ ///
+ ///
+ /// Flags that control the behavior of a peer in a graph. The default is does not have flags set. The valid value is identified
+ /// in the following table.
+ ///
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// PEER_GRAPH_PROPERTY_DEFER_EXPIRATION
+ ///
+ /// Specifies when to expire a graph record. When a graph is not connected and this flag is set, expiration does not occur until
+ /// the graph connects to at least one other member.
+ ///
+ ///
+ ///
+ ///
+ public PEER_GRAPH_PROPERTY_FLAGS dwFlags;
+
+ ///
+ ///
+ /// Specifies the scope in which the peer graph ID is published. The default value is global. Valid values are identified in the
+ /// following table.
+ ///
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// PEER_GRAPH_SCOPE_GLOBAL
+ /// Scope includes the Internet.
+ ///
+ /// -
+ /// PEER_GRAPH_SCOPE_LINK_LOCAL
+ /// Scope is restricted to a local subnet.
+ ///
+ /// -
+ /// PEER_GRAPH_SCOPE_SITE_LOCAL
+ /// Scope is restricted to a site, for example, a corporation intranet.
+ ///
+ ///
+ ///
+ public uint dwScope;
+
+ ///
+ /// Specifies the value that indicates the largest record that can be added to a peer graph. A valid value is zero (0), which
+ /// indicates that the default maximum record size is used (60 megabytes), and any value between 1024 bytes and 60 megabytes.
+ ///
+ public uint dwMaxRecordSize;
+
+ ///
+ /// Specifies the unique identifier for a peer graph. This ID must be unique for the computer/user pair. This member is required
+ /// and has no default value. If the string value is greater than 256 characters (including the null terminator), an error is returned.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzGraphId;
+
+ ///
+ /// Specifies the unique identifier for the creator of a peer graph. This member is required and has no default value. If the
+ /// string value is greater than 256 characters (including the null terminator), an error is returned.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzCreatorId;
+
+ ///
+ /// Specifies the friendly name of a peer graph. This member is optional and can be NULL. The default value is
+ /// NULL. The maximum length of this string is 256 characters, including the null terminator.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzFriendlyName;
+
+ ///
+ /// Specifies the comment used to describe a peer graph. This member is optional and can be NULL. The default value is
+ /// NULL. The maximum length of this string is 512 characters, including the null terminator.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzComment;
+
+ ///
+ /// Specifies the number of seconds before a presence record expires. The default value is 300 seconds (5 minutes). Do not set
+ /// the value of ulPresenceLifetime to less than 300 seconds. If this member is set less than the 300 (5 minutes) default
+ /// value, then undefined behavior can occur.
+ ///
+ public uint ulPresenceLifetime;
+
+ ///
+ ///
+ /// Specifies how many presence records the Peer Infrastructure keeps in a peer graph at one time. A node that has its presence
+ /// published can be enumerated by all other nodes with PeerGraphEnumNodes. Specify how presence records for users are published
+ /// by specifying one of the values identified in the following table.
+ ///
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// -1
+ /// Presence records are automatically published for all users.
+ ///
+ /// -
+ /// 0
+ /// Presence records are not automatically published.
+ ///
+ /// -
+ /// 1-N
+ ///
+ /// Up to N number of presence records are published at one time. The presence records that are published are randomly chosen by
+ /// the Peer Graphing Infrastructure.
+ ///
+ ///
+ ///
+ ///
+ public uint cPresenceMax;
+ }
+
+ /// The PEER_GROUP_EVENT_DATA structure contains information about a specific peer group event that has occurred.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_group_event_data-r1 typedef struct peer_group_event_data_tag {
+ // PEER_GROUP_EVENT_TYPE eventType; union { PEER_GROUP_STATUS dwStatus; PEER_EVENT_INCOMING_DATA incomingData;
+ // PEER_EVENT_RECORD_CHANGE_DATA recordChangeData; PEER_EVENT_CONNECTION_CHANGE_DATA connectionChangeData;
+ // PEER_EVENT_MEMBER_CHANGE_DATA memberChangeData; HRESULT hrConnectionFailedReason; }; } PEER_GROUP_EVENT_DATA, *PEER_GROUP_EVENT_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_group_event_data_tag~r1")]
+ [StructLayout(LayoutKind.Explicit)]
+ public struct PEER_GROUP_EVENT_DATA
+ {
+ ///
+ /// PEER_GROUP_EVENT_TYPE enumeration value that specifies the type of peer group event that occurred. The type of event
+ /// dictates the subsequent structure chosen from the union; for example, if this value is set to
+ /// PEER_GROUP_EVENT_INCOMING_DATA, the populated union member is incomingData.
+ ///
+ [FieldOffset(0)]
+ public PEER_GROUP_EVENT_TYPE eventType;
+
+ ///
+ /// Specifies the PEER_GROUP_STATUS flag values that indicate the new status of the peer group. This field is populated if a
+ /// PEER_GROUP_EVENT_STATUS_CHANGED event is raised.
+ ///
+ [FieldOffset(4)]
+ public PEER_GROUP_STATUS dwStatus;
+
+ ///
+ /// Specifies the PEER_EVENT_INCOMING_DATA structure that contains information on incoming data from a peer. This structure is
+ /// populated if a PEER_GROUP_EVENT_INCOMING_DATA event is raised.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_INCOMING_DATA incomingData;
+
+ ///
+ /// Specifies the PEER_EVENT_RECORD_CHANGE_DATA structure that contains data that describes a record change. This structure is
+ /// populated if a PEER_GROUP_EVENT_RECORD_CHANGED event is raised.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_RECORD_CHANGE_DATA recordChangeData;
+
+ ///
+ /// PEER_EVENT_CONNECTION_CHANGE_DATA structure that contains information when a direct or neighbor connection has changed. This
+ /// structure is populated if a PEER_GROUP_EVENT_DIRECT_CONNECTION or PEER_GROUP_EVENT_NEIGHBOR_CONNECTION event is raised.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_CONNECTION_CHANGE_DATA connectionChangeData;
+
+ ///
+ /// PEER_EVENT_MEMBER_CHANGE_DATA structure that contains data when the status of a peer group member changes. This structure is
+ /// populated if a PEER_GROUP_EVENT_MEMBER_CHANGED event is raised.
+ ///
+ [FieldOffset(4)]
+ public PEER_EVENT_MEMBER_CHANGE_DATA memberChangeData;
+
+ ///
+ ///
+ /// HRESULT that indicates the type of connection failure that occurred. This value is populated if a
+ /// PEER_GROUP_EVENT_CONNECTION_FAILED event is raised. This value is one of the following:
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_E_NO_MEMBERS_FOUND
+ /// No available peers within the peer group were found to connect to.
+ ///
+ /// -
+ /// PEER_E_NO_MEMBER_CONNECTIONS
+ /// No member connections were available.
+ ///
+ /// -
+ /// PEER_E_UNABLE_TO_LISTEN
+ /// The peer was unable to receive connection data for an unspecified reason.
+ ///
+ /// -
+ /// PEER_E_NOT_AUTHORIZED
+ ///
+ /// An attempt has been made to perform an unauthorized operation. For example, attempting to join a group with an invalid password.
+ ///
+ ///
+ ///
+ ///
+ [FieldOffset(4)]
+ public HRESULT hrConnectionFailedReason;
+ }
+
+ ///
+ /// The PEER_GROUP_EVENT_REGISTRATION structure defines the particular peer group event a member can register for.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_group_event_registration typedef struct
+ // peer_group_event_registration_tag { PEER_GROUP_EVENT_TYPE eventType; GUID *pType; } PEER_GROUP_EVENT_REGISTRATION, *PEER_GROUP_EVENT_REGISTRATION*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_group_event_registration_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_GROUP_EVENT_REGISTRATION
+ {
+ /// PEER_GROUP_EVENT_TYPE that specifies the peer group event type to register for.
+ public PEER_GROUP_EVENT_TYPE eventType;
+
+ ///
+ ///
+ /// GUID value that identifies the type of record or data message that raises an event of the type specified by
+ /// eventType. For example, if the peer wishes to be notified about all changes to a specific record type, the GUID that
+ /// corresponds to this record type must be supplied in this field and PEER_GROUP_RECORD_CHANGED must be in eventType.
+ ///
+ /// This member is only populated (not NULL) when eventType is either PEER_GROUP_EVENT_RECORD_CHANGED or PEER_GROUP_EVENT_INCOMING_DATA.
+ ///
+ public IntPtr pType;
+ }
+
+ /// The PEER_GROUP_PROPERTIES structure contains data about the membership policy of a peer group.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_group_properties typedef struct peer_group_properties_tag {
+ // DWORD dwSize; DWORD dwFlags; PWSTR pwzCloud; PWSTR pwzClassifier; PWSTR pwzGroupPeerName; PWSTR pwzCreatorPeerName; PWSTR
+ // pwzFriendlyName; PWSTR pwzComment; ULONG ulMemberDataLifetime; ULONG ulPresenceLifetime; DWORD dwAuthenticationSchemes; PWSTR
+ // pwzGroupPassword; PEER_ROLE_ID groupPasswordRole; } PEER_GROUP_PROPERTIES, *PEER_GROUP_PROPERTIES*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_group_properties_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_GROUP_PROPERTIES
+ {
+ /// Size of the structure, in bytes.
+ public uint dwSize;
+
+ ///
+ /// PEER_GROUP_PROPERTY_FLAGS flags that describe the behavior of a peer group. The default value is zero (0), which indicates
+ /// that flags are not set.
+ ///
+ public PEER_GROUP_PROPERTY_FLAGS dwFlags;
+
+ ///
+ /// Specifies the name of the Peer Name Resolution Protocol (PNRP) cloud that a peer group participates in. The default value is
+ /// "global", if this member is NULL.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzCloud;
+
+ ///
+ /// Specifies the classifier used to identify the authority of a peer group peer name for registration or resolution within a
+ /// PNRP cloud. The maximum size of this field is 149 Unicode characters. This member can be NULL.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzClassifier;
+
+ ///
+ /// Specifies the name of a peer group that is registered with the PNRP service. The maximum size of this field is 137 Unicode characters.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzGroupPeerName;
+
+ ///
+ /// Specifies the peer name associated with the Peer group creator. The maximum size of this field is 137 Unicode characters. If
+ /// this structure member is NULL, the implementation uses the identity obtained from PeerIdentityGetDefault.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzCreatorPeerName;
+
+ /// Specifies the friendly (display) name of a peer group. The maximum size of this field is 255 characters.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzFriendlyName;
+
+ /// Contains a comment used to describe a peer group. The maximum size of this field is 255 characters.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzComment;
+
+ ///
+ ///
+ /// Specifies the lifetime, in seconds, of peer group member data (PEER_MEMBER). The minimum value for this field is 8 hours,
+ /// and the maximum is 10 years. The default value is 2,419,200 seconds, or 28 days.
+ ///
+ ///
+ /// If this value is set to zero (0), member data has the maximum allowable lifetime, which is the time remaining in the
+ /// lifetime of the administrator who issues the credentials for a member.
+ ///
+ ///
+ public uint ulMemberDataLifetime;
+
+ ///
+ /// Specifies the lifetime, in seconds, of presence information published to a peer group. The default value is 300 seconds. Do
+ /// not set the value of ulPresenceLifetime to less than 300 seconds. If this member is set to less than the 300–second
+ /// default value, then undefined behavior can occur.
+ ///
+ public uint ulPresenceLifetime;
+
+ ///
+ /// Windows Vista or later. Logical OR of PEER_GROUP_AUTHENTICATION_SCHEME enumeration values that indicate the types of
+ /// authentication supported by the peer group.
+ ///
+ public PEER_GROUP_AUTHENTICATION_SCHEME dwAuthenticationSchemes;
+
+ ///
+ /// Windows Vista or later. Pointer to a Unicode string that contains the password used to authenticate peers attempting
+ /// to join the peer group.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzGroupPassword;
+
+ ///
+ /// Windows Vista or later. GUID value that indicates the peer group role for which the password is required for authentication.
+ ///
+ public Guid groupPasswordRole;
+ }
+
+ /// The PEER_INVITATION structure contains a request to initiate or join a peer collaboration activity.
+ ///
+ /// An invitation request is typically sent by a peer after a contact appears online within the peer collaboration network and a
+ /// call to PeerCollabEnumApplications returns a common software application (represented as a application GUID) available on the
+ /// contact's endpoint.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_invitation typedef struct peer_invitation_tag { GUID
+ // applicationId; PEER_DATA applicationData; PWSTR pwzMessage; } PEER_INVITATION, *PEER_INVITATION*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_invitation_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_INVITATION
+ {
+ ///
+ /// GUID value that uniquely identifies the registered software or software component for the peer collaboration activity.
+ ///
+ public Guid applicationId;
+
+ ///
+ /// PEER_DATA structure that contains opaque data describing possible additional application-specific settings (for example, an
+ /// address and port on which the activity will occur, or a specific video codec to use). This data is limited to 16K.
+ ///
+ public PEER_DATA applicationData;
+
+ ///
+ /// Zero-terminated Unicode string that contains a specific request message to the invitation recipient. The message is limited
+ /// to 255 unicode characters.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzMessage;
+ }
+
+ ///
+ /// The PEER_INVITATION_INFO structure defines information about an invitation to join a peer group. Invitations are
+ /// represented as Unicode strings. To obtain this structure, pass the XML invitation string created by PeerGroupCreateInvitation to PeerGroupParseInvitation.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_invitation_info typedef struct peer_invitation_info_tag {
+ // DWORD dwSize; DWORD dwFlags; PWSTR pwzCloudName; DWORD dwScope; DWORD dwCloudFlags; PWSTR pwzGroupPeerName; PWSTR
+ // pwzIssuerPeerName; PWSTR pwzSubjectPeerName; PWSTR pwzGroupFriendlyName; PWSTR pwzIssuerFriendlyName; PWSTR
+ // pwzSubjectFriendlyName; FILETIME ftValidityStart; FILETIME ftValidityEnd; ULONG cRoles; PEER_ROLE_ID *pRoles; ULONG cClassifiers;
+ // PWSTR *ppwzClassifiers; CERT_PUBLIC_KEY_INFO *pSubjectPublicKey; PEER_GROUP_AUTHENTICATION_SCHEME authScheme; }
+ // PEER_INVITATION_INFO, *PEER_INVITATION_INFO*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_invitation_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_INVITATION_INFO
+ {
+ /// Specifies the size of this structure, in bytes.
+ public uint dwSize;
+
+ /// Must be set to 0x00000000.
+ public uint dwFlags;
+
+ /// Pointer to a Unicode string that specifies the PNRP cloud name.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzCloudName;
+
+ ///
+ /// Specifies the scope under which the peer group was registered.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PNRP_GLOBAL_SCOPE
+ /// Global scope, including the Internet.
+ ///
+ /// -
+ /// PNRP_LOCAL_SCOPE
+ /// Local scope.
+ ///
+ /// -
+ /// PNRP_LINK_LOCAL_SCOPE
+ /// Link-local scope.
+ ///
+ ///
+ ///
+ public PNRP_SCOPE dwScope;
+
+ ///
+ /// Specifies a set of flags that describe PNRP cloud features.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PNRP_CLOUD_NO_FLAGS 0
+ /// No flags are set.
+ ///
+ /// -
+ /// PNRP_CLOUD_NAME_LOCAL 1
+ /// The cloud name is not available on other computers; it is locally defined.
+ ///
+ ///
+ ///
+ public PNRP_CLOUD_FLAGS dwCloudFlags;
+
+ /// Pointer to a Unicode string that specifies the peer name of the peer group.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzGroupPeerName;
+
+ /// Pointer to a Unicode string that specifies the PNRP name of the peer issuing the invitation.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzIssuerPeerName;
+
+ /// Pointer to a Unicode string that specifies the PNRP name of the peer that receives the invitation.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzSubjectPeerName;
+
+ /// Pointer to a Unicode string that specifies the friendly (display) name of the peer group.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzGroupFriendlyName;
+
+ /// Pointer to a Unicode string that specifies the friendly (display) name of the peer issuing the invitation.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzIssuerFriendlyName;
+
+ /// Pointer to a Unicode string that specifies the friendly (display) name of the peer that receives the invitation.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzSubjectFriendlyName;
+
+ /// Specifies a UTC FILETIME value that indicates when the invitation becomes valid.
+ public FILETIME ftValidityStart;
+
+ /// Specifies a UTC FILETIME value that indicates when the invitation becomes invalid.
+ public FILETIME ftValidityEnd;
+
+ /// Specifies the number of role GUIDs present in pRoles.
+ public uint cRoles;
+
+ ///
+ /// Pointer to a list of GUIDs that specifies the combined set of available roles. The available roles are as follows.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_GROUP_ROLE_ADMIN
+ ///
+ /// This role can issue invitations, renew memberships, modify peer group properties, publish and update records, and renew the
+ /// GMC of other administrators.
+ ///
+ ///
+ /// -
+ /// PEER_GROUP_ROLE_MEMBER
+ /// The role can publish records to the peer group database.
+ ///
+ ///
+ ///
+ public IntPtr pRoles;
+
+ ///
+ /// Unsigned integer value that contains the number of string values listed in ppwzClassifiers. This field is reserved
+ /// for future use.
+ ///
+ public uint cClassifiers;
+
+ /// List of pointers to Unicode strings. This field is reserved for future use.
+ public IntPtr ppwzClassifiers;
+
+ ///
+ /// Pointer to a CERT_PUBLIC_KEY_INFO structure that contains the recipient's returned public key and the encryption
+ /// algorithm type it uses.
+ ///
+ public IntPtr pSubjectPublicKey;
+
+ ///
+ /// Windows Vista or later. The PEER_GROUP_AUTHENTICATION_SCHEME enumeration value that indicates the type of
+ /// authentication used to validate the peer group invitee.
+ ///
+ public PEER_GROUP_AUTHENTICATION_SCHEME authScheme;
+ }
+
+ ///
+ /// The PEER_INVITATION_RESPONSE structure contains a response to an invitation to join a peer collaboration activity.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_invitation_response typedef struct
+ // peer_invitation_response_tag { PEER_INVITATION_RESPONSE_TYPE action; PWSTR pwzMessage; HRESULT hrExtendedInfo; }
+ // PEER_INVITATION_RESPONSE, *PEER_INVITATION_RESPONSE*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_invitation_response_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_INVITATION_RESPONSE
+ {
+ ///
+ /// PEER_INVITATION_RESPONSE_TYPE enumeration value that specifies the action the peer takes in response to the invitation.
+ ///
+ public PEER_INVITATION_RESPONSE_TYPE action;
+
+ /// Reserved. This member must be set to NULL, and is set exclusively by the Peer Collaboration infrastructure.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzMessage;
+
+ ///
+ /// Any extended information that is part of the response. This can include an error code corresponding to the failure on the
+ /// recipient of the invitation.
+ ///
+ public HRESULT hrExtendedInfo;
+ }
+
+ /// The PEER_MEMBER structure contains information that describes a member of a peer group.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_member typedef struct peer_member_tag { DWORD dwSize; DWORD
+ // dwFlags; PWSTR pwzIdentity; PWSTR pwzAttributes; ULONGLONG ullNodeId; ULONG cAddresses; PEER_ADDRESS *pAddresses;
+ // PEER_CREDENTIAL_INFO *pCredentialInfo; } PEER_MEMBER, *PEER_MEMBER*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_member_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_MEMBER
+ {
+ /// Specifies the size of this structure, in bytes.
+ public uint dwSize;
+
+ ///
+ /// PEER_MEMBER_FLAGS enumeration value that specifies the state of the member.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEER_MEMBER_PRESENT
+ /// The member is present in the peer group.
+ ///
+ ///
+ ///
+ public PEER_MEMBER_FLAGS dwFlags;
+
+ /// Pointer to a Unicode string that specifies the peer name of the member.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzIdentity;
+
+ ///
+ /// Pointer to a unicode string that specifies the attributes of the member. The format of this string is defined by the application.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzAttributes;
+
+ ///
+ /// Unsigned 64-bit integer that contains the node ID. The same peer can have several node IDs, each identifying a different
+ /// node that participates in a different peer group.
+ ///
+ public ulong ullNodeId;
+
+ /// Specifies the number of IP addresses listed in pAddress.
+ public uint cAddresses;
+
+ /// Pointer to a list of PEER_ADDRESS structures used by the member.
+ public IntPtr pAddresses;
+
+ /// Pointer to a PEER_CREDENTIAL_INFO structure that contains information about the security credentials of a member.
+ public IntPtr pCredentialInfo;
+ }
+
+ /// The PEER_NAME_PAIR structure contains the results of a call to PeerGetNextItem.
+ ///
+ /// This structure is used when enumerating peer identities and peer groups associated with a specific identity.
+ ///
+ /// When enumerating peer identities, each PEER_NAME_PAIR structure contains a peer name and the friendly name of the identity.
+ ///
+ ///
+ /// When enumerating peer groups, each PEER_NAME_PAIR structure contains the peer name and friendly name of the corresponding
+ /// peer group.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_name_pair typedef struct peer_name_pair_tag { DWORD dwSize;
+ // PWSTR pwzPeerName; PWSTR pwzFriendlyName; } PEER_NAME_PAIR, *PEER_NAME_PAIR*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_name_pair_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_NAME_PAIR
+ {
+ /// Specifies the size, in bytes, of this structure.
+ public uint dwSize;
+
+ /// Specifies the peer name of the peer identity or peer group.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzPeerName;
+
+ /// Specifies the friendly name of the peer identity or peer group.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzFriendlyName;
+ }
+
+ /// The PEER_NODE_INFO structure contains information that is specific to a particular node in a peer graph.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_node_info typedef struct peer_node_info_tag { DWORD dwSize;
+ // ULONGLONG ullNodeId; PWSTR pwzPeerId; ULONG cAddresses; PEER_ADDRESS* pAddresses; PWSTR pwzAttributes; } PEER_NODE_INFO, *PEER_NODE_INFO*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_node_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_NODE_INFO
+ {
+ ///
+ /// Specifies the size of the data structure. Set the value to sizeof( PEER_NODE_INFO). This member is required and has
+ /// no default value.
+ ///
+ public uint dwSize;
+
+ ///
+ /// Specifies a unique ID that identifies an application's connection to its neighbor. An application cannot set the value of
+ /// this member, it is created by the Peer Graphing Infrastructure.
+ ///
+ public ulong ullNodeId;
+
+ ///
+ /// Specifies the ID of this peer. This value is set for the application by the Peer Graphing Infrastructure. when the
+ /// application creates or opens a peer graph.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzPeerId;
+
+ /// Specifies the number of addresses in pAddresses. This member is required and has no default value.
+ public uint cAddresses;
+
+ ///
+ /// Points to an array of PEER_ADDRESS structures that indicate which addresses and ports this instance is listening to for
+ /// group traffic. This member is required and has no default value.
+ ///
+ public IntPtr pAddresses;
+
+ ///
+ /// Points to a string that contains the attributes that describe this particular node. This string is a free-form text string
+ /// that is specific to the application. This parameter is optional; the default value is NULL.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzAttributes;
+ }
+
+ ///
+ /// The PEER_OBJECT structure contains application-specific run-time information that can be shared with trusted contacts
+ /// within a peer collaboration network.
+ ///
+ ///
+ ///
+ /// Peer objects are run-time data items associated with a particular application, such as a picture or avatar, a certificate, or a
+ /// specific description. Each peer object must be smaller than 16K in size.
+ ///
+ ///
+ /// Trusted contacts watching this peer object will have a PEER_EVENT_OBJECT_CHANGED event raised on them signaling this peer
+ /// object's change in status.
+ ///
+ ///
+ /// Peer object information is contained in the data member of this structure and represented as a byte buffer with a maximum
+ /// size of 16K.
+ ///
+ /// The lifetime of a peer object is tied to the lifetime of the application that registered it.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_object typedef struct peer_object_tag { GUID id; PEER_DATA
+ // data; DWORD dwPublicationScope; } PEER_OBJECT, *PEER_OBJECT*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_object_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_OBJECT
+ {
+ /// GUID value under which the peer object is uniquely registered.
+ public Guid id;
+
+ /// PEER_DATA structure that contains information which describes the peer object.
+ public PEER_DATA data;
+
+ /// PEER_PUBLICATION_SCOPE enumeration value that specifies the publication scope for this peer object.
+ public PEER_PUBLICATION_SCOPE dwPublicationScope;
+ }
+
+ /// The PEER_PEOPLE_NEAR_ME structure contains information about a peer in the same logical or virtual subnet.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_people_near_me typedef struct peer_people_near_me_tag { PWSTR
+ // pwzNickName; PEER_ENDPOINT endpoint; GUID id; } PEER_PEOPLE_NEAR_ME, *PEER_PEOPLE_NEAR_ME*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_people_near_me_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_PEOPLE_NEAR_ME
+ {
+ /// Zero-terminated Unicode string that contains the nickname of the contact.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzNickName;
+
+ /// PEER_ENDPOINT structure that contains the IPv6 network address of the peer whose endpoint shares the same subnet.
+ public PEER_ENDPOINT endpoint;
+
+ ///
+ /// GUID value that contains the unique ID value for this peer. Since this value uniquely identifies a peer endpoint, the
+ /// display name and even the associated IPv6 address can be changed with deleting the rest of the peer information.
+ ///
+ public Guid id;
+ }
+
+ /// The PEER_PNRP_CLOUD_INFO structure contains information about a Peer Name Resolution Protocol (PNRP) cloud.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_pnrp_cloud_info typedef struct peer_pnrp_cloud_info_tag {
+ // PWSTR pwzCloudName; PNRP_SCOPE dwScope; DWORD dwScopeId; } PEER_PNRP_CLOUD_INFO, *PEER_PNRP_CLOUD_INFO*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_pnrp_cloud_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_PNRP_CLOUD_INFO
+ {
+ ///
+ /// Pointer to a zero-terminated Unicode string that contains the name of the PNRP cloud. The maximum size of this name is 256 characters.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzCloudName;
+
+ ///
+ /// Constant value that specifies the network scope of the PNRP cloud.
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PNRP_SCOPE_ANY 0
+ /// All IP addresses are allowed to register with the PNRP cloud.
+ ///
+ /// -
+ /// PNRP_GLOBAL_SCOPE 1
+ /// The scope is global; all valid IP addresses are allowed to register with the PNRP cloud.
+ ///
+ /// -
+ /// PNRP_SITE_LOCAL_SCOPE 2
+ /// The scope is site-local; only IP addresses defined for the site are allowed to register with the PNRP cloud.
+ ///
+ /// -
+ /// PNRP_LINK_LOCAL_SCOPE 3
+ ///
+ /// The scope is link-local; only IP addresses defined for the local area network are allowed to register with the PNRP cloud.
+ ///
+ ///
+ ///
+ ///
+ public PNRP_SCOPE dwScope;
+
+ /// The ID of a specific IP address scope defined for the PNRP cloud.
+ public uint dwScopeId;
+ }
+
+ /// The PEER_PNRP_ENDPOINT_INFO structure contains the IP addresses and data associated with a peer endpoint.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_pnrp_endpoint_info typedef struct peer_pnrp_endpoint_info_tag
+ // { PWSTR pwzPeerName; ULONG cAddresses; SOCKADDR **ppAddresses; PWSTR pwzComment; PEER_DATA payload; } PEER_PNRP_ENDPOINT_INFO, *PEER_PNRP_ENDPOINT_INFO*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_pnrp_endpoint_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_PNRP_ENDPOINT_INFO
+ {
+ /// The peer name associated with this peer endpoint.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzPeerName;
+
+ /// The number of SOCKADDR structures in pAddresses.
+ public uint cAddresses;
+
+ ///
+ /// Pointer to an array of pointers to SOCKADDR structures that contain the IP addresses for the peer endpoint's network interface.
+ ///
+ public IntPtr ppAddresses;
+
+ /// Pointer to a zero-terminated Unicode string that contains a comment for this peer endpoint.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzComment;
+
+ ///
+ /// Pointer to a PEER_DATA structure that contains application-specific data for the peer endpoint (such as a message or an image).
+ ///
+ public PEER_DATA payload;
+ }
+
+ ///
+ /// The PEER_PNRP_REGISTRATION_INFO structure contains the information provided by a peer identity when it registers with a
+ /// PNRP cloud.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_pnrp_registration_info typedef struct
+ // peer_pnrp_registration_info_tag { PWSTR pwzCloudName; PWSTR pwzPublishingIdentity; ULONG cAddresses; SOCKADDR **ppAddresses; WORD
+ // wPort; PWSTR pwzComment; PEER_DATA payload; } PEER_PNRP_REGISTRATION_INFO, *PEER_PNRP_REGISTRATION_INFO*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_pnrp_registration_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_PNRP_REGISTRATION_INFO
+ {
+ ///
+ /// Pointer to a Unicode string that contains the name of the PNRP cloud for which this peer identity is requesting
+ /// registration. If NULL, the registration will be made in all clouds. It is possible to use the special value
+ /// PEER_PNRP_ALL_LINK_CLOUDS to register in all link local clouds.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzCloudName;
+
+ /// Pointer to a Unicode string that contains the name of the peer identity requesting registration.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzPublishingIdentity;
+
+ ///
+ /// The number of SOCKADDR structures in ppAddresses. It is possible to use the special value PEER_PNRP_AUTO_ADDRESSES to
+ /// have the infrastructure automatically choose addresses.
+ ///
+ public uint cAddresses;
+
+ ///
+ /// Pointer to an array of pointers to SOCKADDR structures that contain the IP addresses bound to the network interface of the
+ /// peer identity requesting registration.
+ ///
+ public IntPtr ppAddresses;
+
+ /// The network interface port assigned to the address that the peer is publishing.
+ public ushort wPort;
+
+ /// Pointer to a zero-terminated Unicode string that contains a comment for this peer endpoint.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzComment;
+
+ ///
+ /// A PEER_DATA structure that contains a pointer to an opaque byte buffer containing application-specific data for the peer
+ /// endpoint (such as a message or an image).
+ ///
+ public PEER_DATA payload;
+ }
+
+ /// The PEER_PRESENCE_INFO structure contains specific peer presence information.
+ ///
+ /// Peer "presence" is information about a specific peer's level of participation in a peer collaboration network, such as whether
+ /// or not the peer has logged into or out of the peer collaboration network, or has set a specific status (for example, "Busy, "Away").
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_presence_info typedef struct peer_presence_info_tag {
+ // PEER_PRESENCE_STATUS status; PWSTR pwzDescriptiveText; } PEER_PRESENCE_INFO, *PEER_PRESENCE_INFO*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_presence_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_PRESENCE_INFO
+ {
+ ///
+ /// PEER_PRESENCE_STATUS enumeration value that indicates the current availability or level of participation by the peer in a
+ /// peer collaboration network.
+ ///
+ public PEER_PRESENCE_STATUS status;
+
+ ///
+ /// Zero-terminated Unicode string that contains a user- or application-defined message that expands upon the current status
+ /// value. This string is limited to 255 characters.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzDescriptiveText;
+ }
+
+ /// The PEER_RECORD structure contains the record object that an application uses.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_record typedef struct peer_record_tag { DWORD dwSize; GUID
+ // type; GUID id; DWORD dwVersion; DWORD dwFlags; PWSTR pwzCreatorId; PWSTR pwzModifiedById; PWSTR pwzAttributes; FILETIME
+ // ftCreation; FILETIME ftExpiration; FILETIME ftLastModified; PEER_DATA securityData; PEER_DATA data; } PEER_RECORD, *PEER_RECORD*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_record_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_RECORD
+ {
+ /// Specifies the size of a structure. Set the value to sizeof( PEER_RECORD).
+ public uint dwSize;
+
+ ///
+ /// Specifies the type of record. The type is a GUID that an application must specify. The GUID represents a
+ /// unique record type, for example, a chat record.
+ ///
+ public Guid type;
+
+ ///
+ /// Specifies the unique ID of a record. The Peer Infrastructure supplies this ID. This parameter is ignored in calls to
+ /// PeerGroupAddRecord. An application cannot modify this member.
+ ///
+ public Guid id;
+
+ ///
+ /// Specifies the version of a record that the Peer Infrastructure supplies when an application calls PeerGraphAddRecord or
+ /// PeerGraphUpdateRecord. An application cannot modify this member.
+ ///
+ public uint dwVersion;
+
+ ///
+ ///
+ /// Specifies the flags that indicate special processing, which must be applied to a record. The following table identifies the
+ /// valid values.
+ ///
+ ///
+ ///
+ /// Value
+ /// Description
+ ///
+ /// -
+ /// PEER_RECORD_FLAG_AUTOREFRESH
+ /// Indicates that a record is automatically refreshed when it is ready to expire.
+ ///
+ /// -
+ /// PEER_RECORD_FLAG_DELETED
+ /// Indicates that a record is marked as deleted.
+ ///
+ ///
+ /// Note An application cannot set these flags.
+ ///
+ public PEER_RECORD_FLAGS dwFlags;
+
+ ///
+ /// Pointer to the unique ID of a record creator. This member is set to NULL for calls to PeerGraphAddRecord and
+ /// PeerGraphUpdateRecord. An application cannot set this member.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzCreatorId;
+
+ /// Specifies the unique ID of the last person who changes a record. An application cannot set this member.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzModifiedById;
+
+ ///
+ ///
+ /// Pointer to the set of attribute name and value pairs that are associated with a record. This member points to an XML string.
+ /// Record attributes are specified as an XML string, and they must be consistent with the Peer Infrastructure record attribute
+ /// schema. For a complete explanation of the XML schema, see Record Attribute Schema.
+ ///
+ ///
+ /// The Peer Infrastructure reserves several attribute names that a user cannot set. The following list identifies the reserved
+ /// attribute names:
+ ///
+ ///
+ /// -
+ /// peerlastmodifiedby
+ ///
+ /// -
+ /// peercreatorid
+ ///
+ /// -
+ /// peerlastmodificationtime
+ ///
+ /// -
+ /// peerrecordid
+ ///
+ /// -
+ /// peerrecordtype
+ ///
+ /// -
+ /// peercreationtime
+ ///
+ /// -
+ /// peerlastmodificationtime
+ ///
+ ///
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzAttributes;
+
+ ///
+ /// Specifies the Coordinated Universal Time (UTC) that a record is created. The Peer Infrastructure supplies this value, and
+ /// the value is set to zero (0) in calls to PeerGroupAddRecord. An application cannot set this member.
+ ///
+ public FILETIME ftCreation;
+
+ ///
+ ///
+ /// The UTC time that a record expires. This member is required. It can be updated to a time value greater than the originally
+ /// specified time value, but it cannot be less than the originally specified value.
+ ///
+ ///
+ /// Note If dwFlags is set to PEER_RECORD_FLAG_AUTOREFRESH, do not set the value of ftExpiration to
+ /// less than four (4) minutes. If this member is set to less than four (4) minutes, undefined behavior can occur.
+ ///
+ ///
+ public FILETIME ftExpiration;
+
+ ///
+ /// The UTC time that a record is modified. The Peer Infrastructure supplies this value. Set this member to NULL when
+ /// calling PeerGraphAddRecord, PeerGraphUpdateRecord, PeerGroupAddRecord, and PeerGroupUpdateRecord. An application cannot set
+ /// this member.
+ ///
+ public FILETIME ftLastModified;
+
+ ///
+ /// Specifies the security data contained in a PEER_DATA structure. The Graphing API uses this member, and provides the security
+ /// provider with a place to store security data, for example, a signature. The Grouping API cannot modify this member.
+ ///
+ public PEER_DATA securityData;
+
+ /// Specifies the actual data that this record contains.
+ public PEER_DATA data;
+ }
+
+ ///
+ /// The PEER_SECURITY_INTERFACE structure specifies the security interfaces that calls to Peer Graphing APIs use to validate,
+ /// secure, and free records. Additionally, it allows an application to specify the path to the .DLL that contains an implementation
+ /// of a security service provider (SSP).
+ ///
+ ///
+ /// If you have developed your own SSP, your application must not call the Peer Graphing API to access data in the graphing
+ /// database; doing so can lead to a deadlock situation. Instead, the application should look at a cached copy of the information.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_security_interface typedef struct peer_security_interface_tag
+ // { DWORD dwSize; PWSTR pwzSspFilename; PWSTR pwzPackageName; ULONG cbSecurityInfo; PBYTE pbSecurityInfo; PVOID pvContext;
+ // PFNPEER_VALIDATE_RECORD pfnValidateRecord; PFNPEER_SECURE_RECORD pfnSecureRecord; PFNPEER_FREE_SECURITY_DATA pfnFreeSecurityData;
+ // PFNPEER_ON_PASSWORD_AUTH_FAILED pfnAuthFailed; } PEER_SECURITY_INTERFACE, *PEER_SECURITY_INTERFACE*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_security_interface_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_SECURITY_INTERFACE
+ {
+ ///
+ /// Specifies the size of the structure. Set the value to sizeof( PEER_SECURITY_INTERFACE). This member is required and
+ /// has no default value.
+ ///
+ public uint dwSize;
+
+ ///
+ /// Specifies the full path and file name of a .DLL that implements the SSP interface. See the SSPI documentation for further
+ /// information on the SSP interface.
+ ///
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzSspFilename;
+
+ /// Specifies the ID of the security module in the SSP to use.
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string pwzPackageName;
+
+ ///
+ /// Specifies the byte count of the pbSecurityInfo member. This member is not required if pbSecurityInfo is
+ /// NULL. However, if pbSecurityInfo is not NULL, this member must have a value.
+ ///
+ public uint cbSecurityInfo;
+
+ ///
+ ///
+ /// Pointer to a buffer that contains the information used to create or open a peer graph. This member is optional and can be NULL.
+ ///
+ ///
+ /// The security data blob pointed to by pbSecurityInfo is copied and then passed to the SSPI function call of AcquireCredentialsHandle.
+ ///
+ ///
+ public IntPtr pbSecurityInfo;
+
+ ///
+ /// Pointer to the security context. This security context is then passed as the first parameter to PFNPEER_VALIDATE_RECORD,
+ /// PFNPEER_FREE_SECURITY_DATA, and PFNPEER_SECURE_RECORD. This member is optional and can be NULL.
+ ///
+ public IntPtr pvContext;
+
+ ///
+ /// Pointer to a callback function that is called when a record requires validation. This member is optional and can be
+ /// NULL. If pfnSecureRecord is NULL, this member must also be NULL.
+ ///
+ [MarshalAs(UnmanagedType.FunctionPtr)]
+ public PFNPEER_VALIDATE_RECORD pfnValidateRecord;
+
+ ///
+ /// Pointer to a callback function that is called when a record must be secured. This member is optional and can be NULL.
+ /// If pfnValidateRecord is NULL, this member must also be NULL.
+ ///
+ [MarshalAs(UnmanagedType.FunctionPtr)]
+ public PFNPEER_SECURE_RECORD pfnSecureRecord;
+
+ ///
+ /// Pointer to a callback function used to free any data allocated by the callback pointed to by pfnSecureRecord. This
+ /// member is optional and can be NULL.
+ ///
+ [MarshalAs(UnmanagedType.FunctionPtr)]
+ public PFNPEER_FREE_SECURITY_DATA pfnFreeSecurityData;
+
+ ///
+ [MarshalAs(UnmanagedType.FunctionPtr)]
+ public PFNPEER_ON_PASSWORD_AUTH_FAILED pfnAuthFailed;
+ }
+
+ /// The PEER_VERSION_DATA structure contains the version information about the Peer Graphing and Grouping APIs.
+ // https://docs.microsoft.com/en-us/windows/win32/api/p2p/ns-p2p-peer_version_data typedef struct peer_version_data_tag { WORD
+ // wVersion; WORD wHighestVersion; } PEER_VERSION_DATA, *PEER_VERSION_DATA*;
+ [PInvokeData("p2p.h", MSDNShortId = "NS:p2p.peer_version_data_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEER_VERSION_DATA
+ {
+ ///
+ /// Specifies the version of the Peer Infrastructure for a caller to use. The version to use is based on the Peer Infrastructure
+ /// DLL installed on a local computer. A high order-byte specifies the minor version (revision) number. A low-order byte
+ /// specifies the major version number.
+ ///
+ public ushort wVersion;
+
+ ///
+ /// Specifies the highest version of the Peer Infrastructure that the Peer DLL installed on the local computer can support.
+ /// Typically, this value is the same as wVersion.
+ ///
+ public ushort wHighestVersion;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/P2P/Vanara.PInvoke.P2P.csproj b/PInvoke/P2P/Vanara.PInvoke.P2P.csproj
new file mode 100644
index 00000000..d0f23def
--- /dev/null
+++ b/PInvoke/P2P/Vanara.PInvoke.P2P.csproj
@@ -0,0 +1,30 @@
+
+
+
+ P2P.dll
+
+
+ PInvoke API (methods, structures and constants) imported from Windows P2P.dll.
+ $(AssemblyName)
+ net20;net35;net40;net45;netstandard2.0;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1
+ Vanara.PInvoke.P2P
+ $(AssemblyName)
+ pinvoke;vanara;net-extensions;interop;P2P
+ Currently implements:
+
+Functions
+DllMain, PeerCollabAddContact, PeerCollabAsyncInviteContact, PeerCollabAsyncInviteEndpoint, PeerCollabCancelInvitation, PeerCollabCloseHandle, PeerCollabDeleteContact, PeerCollabDeleteEndpointData, PeerCollabDeleteObject, PeerCollabEnumApplicationRegistrationInfo, PeerCollabEnumApplications, PeerCollabEnumContacts, PeerCollabEnumEndpoints, PeerCollabEnumObjects, PeerCollabEnumPeopleNearMe, PeerCollabExportContact, PeerCollabGetAppLaunchInfo, PeerCollabGetApplicationRegistrationInfo, PeerCollabGetContact, PeerCollabGetEndpointName, PeerCollabGetEventData, PeerCollabGetInvitationResponse, PeerCollabGetPresenceInfo, PeerCollabGetSigninOptions, PeerCollabInviteContact, PeerCollabInviteEndpoint, PeerCollabParseContact, PeerCollabQueryContactData, PeerCollabRefreshEndpointData, PeerCollabRegisterApplication, PeerCollabRegisterEvent, PeerCollabSetEndpointName, PeerCollabSetObject, PeerCollabSetPresenceInfo, PeerCollabShutdown, PeerCollabSignin, PeerCollabSignout, PeerCollabStartup, PeerCollabSubscribeEndpointData, PeerCollabUnregisterApplication, PeerCollabUnregisterEvent, PeerCollabUnsubscribeEndpointData, PeerCollabUpdateContact, PeerCreatePeerName, PeerEndEnumeration, PeerEnumGroups, PeerEnumIdentities, PeerFreeData, PeerGetItemCount, PeerGetNextItem, PeerGraphShutdown, PeerGraphStartup, PeerGroupAddRecord, PeerGroupClose, PeerGroupCloseDirectConnection, PeerGroupConnect, PeerGroupConnectByAddress, PeerGroupCreate, PeerGroupCreateInvitation, PeerGroupCreatePasswordInvitation, PeerGroupDelete, PeerGroupDeleteRecord, PeerGroupEnumConnections, PeerGroupEnumMembers, PeerGroupEnumRecords, PeerGroupExportConfig, PeerGroupExportDatabase, PeerGroupGetEventData, PeerGroupGetProperties, PeerGroupGetRecord, PeerGroupGetStatus, PeerGroupHandlePowerEvent, PeerGroupImportConfig, PeerGroupImportDatabase, PeerGroupIssueCredentials, PeerGroupJoin, PeerGroupOpen, PeerGroupOpenDirectConnection, PeerGroupParseInvitation, PeerGroupPasswordJoin, PeerGroupPeerTimeToUniversalTime, PeerGroupRegisterEvent, PeerGroupResumePasswordAuthentication, PeerGroupSearchRecords, PeerGroupSendData, PeerGroupSetProperties, PeerGroupShutdown, PeerGroupStartup, PeerGroupUniversalTimeToPeerTime, PeerGroupUnregisterEvent, PeerGroupUpdateRecord, PeerHostNameToPeerName, PeerIdentityCreate, PeerIdentityDelete, PeerIdentityExport, PeerIdentityGetCert, PeerIdentityGetCryptKey, PeerIdentityGetDefault, PeerIdentityGetFriendlyName, PeerIdentityGetXML, PeerIdentityImport, PeerIdentitySetFriendlyName, PeerNameToPeerHostName, PeerPnrpEndResolve, PeerPnrpGetCloudInfo, PeerPnrpGetEndpoint, PeerPnrpRegister, PeerPnrpResolve, PeerPnrpShutdown, PeerPnrpStartResolve, PeerPnrpStartup, PeerPnrpUnregister, PeerPnrpUpdateRegistration, PeerSSPAddCredentials, PeerSSPRemoveCredentials
+
+Structures
+HPEEREVENT, HGRAPH, PEER_ADDRESS, PEER_APP_LAUNCH_INFO, PEER_APPLICATION, PEER_APPLICATION_REGISTRATION_INFO, PEER_COLLAB_EVENT_DATA, PEER_COLLAB_EVENT_REGISTRATION, PEER_CONNECTION_INFO, PEER_CONTACT, PEER_CREDENTIAL_INFO, PEER_DATA, PEER_ENDPOINT, PEER_EVENT_APPLICATION_CHANGED_DATA, PEER_EVENT_CONNECTION_CHANGE_DATA, PEER_EVENT_ENDPOINT_CHANGED_DATA, PEER_EVENT_INCOMING_DATA, PEER_EVENT_MEMBER_CHANGE_DATA, PEER_EVENT_NODE_CHANGE_DATA, PEER_EVENT_OBJECT_CHANGED_DATA, PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA, PEER_EVENT_PRESENCE_CHANGED_DATA, PEER_EVENT_RECORD_CHANGE_DATA, PEER_EVENT_REQUEST_STATUS_CHANGED_DATA, PEER_EVENT_SYNCHRONIZED_DATA, PEER_EVENT_WATCHLIST_CHANGED_DATA, PEER_GRAPH_EVENT_DATA, PEER_GRAPH_EVENT_REGISTRATION, PEER_GRAPH_PROPERTIES, PEER_GROUP_EVENT_DATA, PEER_GROUP_EVENT_REGISTRATION, PEER_GROUP_PROPERTIES, PEER_INVITATION, PEER_INVITATION_INFO, PEER_INVITATION_RESPONSE, PEER_MEMBER, PEER_NAME_PAIR, PEER_NODE_INFO, PEER_OBJECT, PEER_PEOPLE_NEAR_ME, PEER_PNRP_CLOUD_INFO, PEER_PNRP_ENDPOINT_INFO, PEER_PNRP_REGISTRATION_INFO, PEER_PRESENCE_INFO, PEER_RECORD, PEER_SECURITY_INTERFACE, PEER_VERSION_DATA, HPEERENUM, HGROUP
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PInvoke/Shared/WinError/HRESULT.Values.cs b/PInvoke/Shared/WinError/HRESULT.Values.cs
index e5366b67..34648222 100644
--- a/PInvoke/Shared/WinError/HRESULT.Values.cs
+++ b/PInvoke/Shared/WinError/HRESULT.Values.cs
@@ -9004,6 +9004,257 @@ namespace Vanara.PInvoke
/// The directory being processed is not empty
public const int COPYENGINE_E_DIR_NOT_EMPTY = unchecked((int)0x8027003D);
+ /// The IPv6 protocol is not installed.
+ public const int PEER_E_IPV6_NOT_INSTALLED = unchecked((int)0x80630001);
+
+ /// The component has not been initialized.
+ public const int PEER_E_NOT_INITIALIZED = unchecked((int)0x80630002);
+
+ /// The required service cannot be started.
+ public const int PEER_E_CANNOT_START_SERVICE = unchecked((int)0x80630003);
+
+ /// The P2P protocol is not licensed to run on this OS.
+ public const int PEER_E_NOT_LICENSED = unchecked((int)0x80630004);
+
+ /// The graph handle is invalid.
+ public const int PEER_E_INVALID_GRAPH = unchecked((int)0x80630010);
+
+ /// The graph database name has changed.
+ public const int PEER_E_DBNAME_CHANGED = unchecked((int)0x80630011);
+
+ /// A graph with the same ID already exists.
+ public const int PEER_E_DUPLICATE_GRAPH = unchecked((int)0x80630012);
+
+ /// The graph is not ready.
+ public const int PEER_E_GRAPH_NOT_READY = unchecked((int)0x80630013);
+
+ /// The graph is shutting down.
+ public const int PEER_E_GRAPH_SHUTTING_DOWN = unchecked((int)0x80630014);
+
+ /// The graph is still in use.
+ public const int PEER_E_GRAPH_IN_USE = unchecked((int)0x80630015);
+
+ /// The graph database is corrupt.
+ public const int PEER_E_INVALID_DATABASE = unchecked((int)0x80630016);
+
+ /// Too many attributes have been used.
+ public const int PEER_E_TOO_MANY_ATTRIBUTES = unchecked((int)0x80630017);
+
+ /// The connection can not be found.
+ public const int PEER_E_CONNECTION_NOT_FOUND = unchecked((int)0x80630103);
+
+ /// The peer attempted to connect to itself.
+ public const int PEER_E_CONNECT_SELF = unchecked((int)0x80630106);
+
+ /// The peer is already listening for connections.
+ public const int PEER_E_ALREADY_LISTENING = unchecked((int)0x80630107);
+
+ /// The node was not found.
+ public const int PEER_E_NODE_NOT_FOUND = unchecked((int)0x80630108);
+
+ /// The Connection attempt failed.
+ public const int PEER_E_CONNECTION_FAILED = unchecked((int)0x80630109);
+
+ /// The peer connection could not be authenticated.
+ public const int PEER_E_CONNECTION_NOT_AUTHENTICATED = unchecked((int)0x8063010A);
+
+ /// The connection was refused.
+ public const int PEER_E_CONNECTION_REFUSED = unchecked((int)0x8063010B);
+
+ /// The peer name classifier is too long.
+ public const int PEER_E_CLASSIFIER_TOO_LONG = unchecked((int)0x80630201);
+
+ /// The maximum number of identities have been created.
+ public const int PEER_E_TOO_MANY_IDENTITIES = unchecked((int)0x80630202);
+
+ /// Unable to access a key.
+ public const int PEER_E_NO_KEY_ACCESS = unchecked((int)0x80630203);
+
+ /// The group already exists.
+ public const int PEER_E_GROUPS_EXIST = unchecked((int)0x80630204);
+
+ /// The requested record could not be found.
+ public const int PEER_E_RECORD_NOT_FOUND = unchecked((int)0x80630301);
+
+ /// Access to the database was denied.
+ public const int PEER_E_DATABASE_ACCESSDENIED = unchecked((int)0x80630302);
+
+ /// The Database could not be initialized.
+ public const int PEER_E_DBINITIALIZATION_FAILED = unchecked((int)0x80630303);
+
+ /// The record is too big.
+ public const int PEER_E_MAX_RECORD_SIZE_EXCEEDED = unchecked((int)0x80630304);
+
+ /// The database already exists.
+ public const int PEER_E_DATABASE_ALREADY_PRESENT = unchecked((int)0x80630305);
+
+ /// The database could not be found.
+ public const int PEER_E_DATABASE_NOT_PRESENT = unchecked((int)0x80630306);
+
+ /// The identity could not be found.
+ public const int PEER_E_IDENTITY_NOT_FOUND = unchecked((int)0x80630401);
+
+ /// The event handle could not be found.
+ public const int PEER_E_EVENT_HANDLE_NOT_FOUND = unchecked((int)0x80630501);
+
+ /// Invalid search.
+ public const int PEER_E_INVALID_SEARCH = unchecked((int)0x80630601);
+
+ /// The search attributes are invalid.
+ public const int PEER_E_INVALID_ATTRIBUTES = unchecked((int)0x80630602);
+
+ /// The invitation is not trusted.
+ public const int PEER_E_INVITATION_NOT_TRUSTED = unchecked((int)0x80630701);
+
+ /// The certchain is too long.
+ public const int PEER_E_CHAIN_TOO_LONG = unchecked((int)0x80630703);
+
+ /// The time period is invalid.
+ public const int PEER_E_INVALID_TIME_PERIOD = unchecked((int)0x80630705);
+
+ /// A circular cert chain was detected.
+ public const int PEER_E_CIRCULAR_CHAIN_DETECTED = unchecked((int)0x80630706);
+
+ /// The certstore is corrupted.
+ public const int PEER_E_CERT_STORE_CORRUPTED = unchecked((int)0x80630801);
+
+ /// The specified PNRP cloud does not exist.
+ public const int PEER_E_NO_CLOUD = unchecked((int)0x80631001);
+
+ /// The cloud name is ambiguous.
+ public const int PEER_E_CLOUD_NAME_AMBIGUOUS = unchecked((int)0x80631005);
+
+ /// The record is invalid.
+ public const int PEER_E_INVALID_RECORD = unchecked((int)0x80632010);
+
+ /// Not authorized.
+ public const int PEER_E_NOT_AUTHORIZED = unchecked((int)0x80632020);
+
+ /// The password does not meet policy requirements.
+ public const int PEER_E_PASSWORD_DOES_NOT_MEET_POLICY = unchecked((int)0x80632021);
+
+ /// The record validation has been deferred.
+ public const int PEER_E_DEFERRED_VALIDATION = unchecked((int)0x80632030);
+
+ /// The group properties are invalid.
+ public const int PEER_E_INVALID_GROUP_PROPERTIES = unchecked((int)0x80632040);
+
+ /// The peername is invalid.
+ public const int PEER_E_INVALID_PEER_NAME = unchecked((int)0x80632050);
+
+ /// The classifier is invalid.
+ public const int PEER_E_INVALID_CLASSIFIER = unchecked((int)0x80632060);
+
+ /// The friendly name is invalid.
+ public const int PEER_E_INVALID_FRIENDLY_NAME = unchecked((int)0x80632070);
+
+ /// Invalid role property.
+ public const int PEER_E_INVALID_ROLE_PROPERTY = unchecked((int)0x80632071);
+
+ /// Invalid classifier property.
+ public const int PEER_E_INVALID_CLASSIFIER_PROPERTY = unchecked((int)0x80632072);
+
+ /// Invalid record expiration.
+ public const int PEER_E_INVALID_RECORD_EXPIRATION = unchecked((int)0x80632080);
+
+ /// Invalid credential info.
+ public const int PEER_E_INVALID_CREDENTIAL_INFO = unchecked((int)0x80632081);
+
+ /// Invalid credential.
+ public const int PEER_E_INVALID_CREDENTIAL = unchecked((int)0x80632082);
+
+ /// Invalid record size.
+ public const int PEER_E_INVALID_RECORD_SIZE = unchecked((int)0x80632083);
+
+ /// Unsupported version.
+ public const int PEER_E_UNSUPPORTED_VERSION = unchecked((int)0x80632090);
+
+ /// The group is not ready.
+ public const int PEER_E_GROUP_NOT_READY = unchecked((int)0x80632091);
+
+ /// The group is still in use.
+ public const int PEER_E_GROUP_IN_USE = unchecked((int)0x80632092);
+
+ /// The group is invalid.
+ public const int PEER_E_INVALID_GROUP = unchecked((int)0x80632093);
+
+ /// No members were found.
+ public const int PEER_E_NO_MEMBERS_FOUND = unchecked((int)0x80632094);
+
+ /// There are no member connections.
+ public const int PEER_E_NO_MEMBER_CONNECTIONS = unchecked((int)0x80632095);
+
+ /// Unable to listen.
+ public const int PEER_E_UNABLE_TO_LISTEN = unchecked((int)0x80632096);
+
+ /// The identity does not exist.
+ public const int PEER_E_IDENTITY_DELETED = unchecked((int)0x806320A0);
+
+ /// The service is not available.
+ public const int PEER_E_SERVICE_NOT_AVAILABLE = unchecked((int)0x806320A1);
+
+ /// THe contact could not be found.
+ public const int PEER_E_CONTACT_NOT_FOUND = unchecked((int)0x80636001);
+
+ /// The graph data was created.
+ public const int PEER_S_GRAPH_DATA_CREATED = unchecked((int)0x00630001);
+
+ /// There is not more event data.
+ public const int PEER_S_NO_EVENT_DATA = unchecked((int)0x00630002);
+
+ /// The graph is already connect.
+ public const int PEER_S_ALREADY_CONNECTED = unchecked((int)0x00632000);
+
+ /// The subscription already exists.
+ public const int PEER_S_SUBSCRIPTION_EXISTS = unchecked((int)0x00636000);
+
+ /// No connectivity.
+ public const int PEER_S_NO_CONNECTIVITY = unchecked((int)0x00630005);
+
+ /// Already a member.
+ public const int PEER_S_ALREADY_A_MEMBER = unchecked((int)0x00630006);
+
+ /// The peername could not be converted to a DNS pnrp name.
+ public const int PEER_E_CANNOT_CONVERT_PEER_NAME = unchecked((int)0x80634001);
+
+ /// Invalid peer host name.
+ public const int PEER_E_INVALID_PEER_HOST_NAME = unchecked((int)0x80634002);
+
+ /// No more data could be found.
+ public const int PEER_E_NO_MORE = unchecked((int)0x80634003);
+
+ /// The existing peer name is already registered.
+ public const int PEER_E_PNRP_DUPLICATE_PEER_NAME = unchecked((int)0x80634005);
+
+ /// The app invite request was cancelled by the user.
+ public const int PEER_E_INVITE_CANCELLED = unchecked((int)0x80637000);
+
+ /// No response of the invite was received.
+ public const int PEER_E_INVITE_RESPONSE_NOT_AVAILABLE = unchecked((int)0x80637001);
+
+ /// User is not signed into serverless presence.
+ public const int PEER_E_NOT_SIGNED_IN = unchecked((int)0x80637003);
+
+ /// The user declined the privacy policy prompt.
+ public const int PEER_E_PRIVACY_DECLINED = unchecked((int)0x80637004);
+
+ /// A timeout occurred.
+ public const int PEER_E_TIMEOUT = unchecked((int)0x80637005);
+
+ /// The address is invalid.
+ public const int PEER_E_INVALID_ADDRESS = unchecked((int)0x80637007);
+
+ /// A required firewall exception is disabled.
+ public const int PEER_E_FW_EXCEPTION_DISABLED = unchecked((int)0x80637008);
+
+ /// The service is blocked by a firewall policy.
+ public const int PEER_E_FW_BLOCKED_BY_POLICY = unchecked((int)0x80637009);
+
+ /// Firewall exceptions are disabled.
+ public const int PEER_E_FW_BLOCKED_BY_SHIELDS_UP = unchecked((int)0x8063700A);
+
+ /// The user declined to enable the firewall exceptions.
+ public const int PEER_E_FW_DECLINED = unchecked((int)0x8063700B);
/// The IAudioClient object is already initialized.
public static readonly HRESULT AUDCLNT_E_ALREADY_INITIALIZED = AUDCLNT_ERR(0x002);
diff --git a/README.md b/README.md
index a43aa184..8cf7cba9 100644
--- a/README.md
+++ b/README.md
@@ -70,6 +70,7 @@ ntdsapi.dll | [Vanara.PInvoke.NTDSApi](https://github.com/dahall/Vanara/blob/mas
ole32.dll, oleaut32.dll, propsys.dll | [Vanara.PInvoke.Ole](https://github.com/dahall/Vanara/blob/master/PInvoke/Ole/CorrelationReport.md) | ![Coverage](https://img.shields.io/badge/82%25-green.svg?style=flat-square) | [![Nuget](https://img.shields.io/nuget/v/Vanara.PInvoke.Ole?label=%20&logo=nuget&style=flat-square)![Nuget](https://img.shields.io/nuget/dt/Vanara.PInvoke.Ole?label=%20&style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Ole)
oleacc.dll | [Vanara.PInvoke.Accessibility](https://github.com/dahall/Vanara/blob/master/PInvoke/Accessibility/CorrelationReport.md) | ![Coverage](https://img.shields.io/badge/100%25-green.svg?style=flat-square) | [![Nuget](https://img.shields.io/nuget/v/Vanara.PInvoke.Accessibility?label=%20&logo=nuget&style=flat-square)![Nuget](https://img.shields.io/nuget/dt/Vanara.PInvoke.Accessibility?label=%20&style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Accessibility)
opcservices.dll | [Vanara.PInvoke.Opc](https://github.com/dahall/Vanara/blob/master/PInvoke/Opc/CorrelationReport.md) | ![Coverage](https://img.shields.io/badge/100%25-green.svg?style=flat-square) | [![Nuget](https://img.shields.io/nuget/v/Vanara.PInvoke.Opc?label=%20&logo=nuget&style=flat-square)![Nuget](https://img.shields.io/nuget/dt/Vanara.PInvoke.Opc?label=%20&style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Opc)
+P2P.dll | [Vanara.PInvoke.P2P](https://github.com/dahall/Vanara/blob/master/PInvoke/P2P/CorrelationReport.md) | ![Coverage](https://img.shields.io/badge/87%25-green.svg?style=flat-square) | [![Nuget](https://img.shields.io/nuget/v/Vanara.PInvoke.P2P?label=%20&logo=nuget&style=flat-square)![Nuget](https://img.shields.io/nuget/dt/Vanara.PInvoke.P2P?label=%20&style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.P2P)
pdh.dll | [Vanara.PInvoke.Pdh](https://github.com/dahall/Vanara/blob/master/PInvoke/Pdh/CorrelationReport.md) | ![Coverage](https://img.shields.io/badge/100%25-green.svg?style=flat-square) | [![Nuget](https://img.shields.io/nuget/v/Vanara.PInvoke.Pdh?label=%20&logo=nuget&style=flat-square)![Nuget](https://img.shields.io/nuget/dt/Vanara.PInvoke.Pdh?label=%20&style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.Pdh)
powrprof.dll | [Vanara.PInvoke.PowrProf](https://github.com/dahall/Vanara/blob/master/PInvoke/PowrProf/CorrelationReport.md) | ![Coverage](https://img.shields.io/badge/100%25-green.svg?style=flat-square) | [![Nuget](https://img.shields.io/nuget/v/Vanara.PInvoke.PowrProf?label=%20&logo=nuget&style=flat-square)![Nuget](https://img.shields.io/nuget/dt/Vanara.PInvoke.PowrProf?label=%20&style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.PowrProf)
ProjectedFSLib.dll | [Vanara.PInvoke.ProjectedFSLib](https://github.com/dahall/Vanara/blob/master/PInvoke/ProjectedFSLib/CorrelationReport.md) | ![Coverage](https://img.shields.io/badge/100%25-green.svg?style=flat-square) | [![Nuget](https://img.shields.io/nuget/v/Vanara.PInvoke.ProjectedFSLib?label=%20&logo=nuget&style=flat-square)![Nuget](https://img.shields.io/nuget/dt/Vanara.PInvoke.ProjectedFSLib?label=%20&style=flat-square)](https://www.nuget.org/packages/Vanara.PInvoke.ProjectedFSLib)
diff --git a/UnitTests/PInvoke/P2P/P2P.csproj b/UnitTests/PInvoke/P2P/P2P.csproj
new file mode 100644
index 00000000..cfbcc422
--- /dev/null
+++ b/UnitTests/PInvoke/P2P/P2P.csproj
@@ -0,0 +1,78 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {BBA10B94-658F-4BD7-A3DD-AA39CDF9A68D}
+ Library
+ Properties
+ UnitTest.PInvoke.P2P
+ v4.7.2
+ 512
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x64
+ true
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ true
+ x64
+
+
+
+
+
+
+ {241f73ee-9298-45c9-b869-a045dff94c03}
+ Vanara.Core
+
+
+ {200d7e57-452a-4a43-a96d-386f7c49e7ba}
+ Vanara.PInvoke.P2P
+
+
+ {a5e519e9-feba-4fe3-93a5-b8269bef72f4}
+ Vanara.PInvoke.Shared
+
+
+ {a96cff10-0967-429a-8700-4a86c97c5603}
+ Shared
+
+
+
+
+ 3.12.0
+
+
+ 3.16.1
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UnitTests/PInvoke/P2P/P2PTests.cs b/UnitTests/PInvoke/P2P/P2PTests.cs
new file mode 100644
index 00000000..1ba8694c
--- /dev/null
+++ b/UnitTests/PInvoke/P2P/P2PTests.cs
@@ -0,0 +1,43 @@
+using NUnit.Framework;
+using NUnit.Framework.Internal;
+using System;
+using System.Runtime.InteropServices;
+using static Vanara.PInvoke.P2P;
+
+namespace Vanara.PInvoke.Tests
+{
+ [TestFixture]
+ public class P2PTests
+ {
+ [OneTimeSetUp]
+ public void _Setup()
+ {
+ //PeerCollabStartup().ThrowIfFailed();
+ //PeerPnrpStartup().ThrowIfFailed();
+ }
+
+ [OneTimeTearDown]
+ public void _TearDown()
+ {
+ //PeerPnrpShutdown();
+ //PeerCollabShutdown();
+ }
+
+ [Test]
+ public void PeerCollabEnumApplicationsTest()
+ {
+ var e = PeerCollabEnumApplications();
+ Assert.NotNull(e);
+ e.WriteValues();
+ }
+
+ [Test]
+ public void EndpointNameTest()
+ {
+ Assert.That(PeerCollabGetEndpointName(out var name), ResultIs.Successful);
+ const string bogusName = "aksjdhflkajsdfkjahsdfkjhsdf";
+ Assert.That(PeerCollabSetEndpointName(bogusName), ResultIs.Successful);
+ Assert.That(PeerCollabSetEndpointName(name), ResultIs.Successful);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Vanara.Library.nuspec b/Vanara.Library.nuspec
index ece6257a..e4679766 100644
--- a/Vanara.Library.nuspec
+++ b/Vanara.Library.nuspec
@@ -42,6 +42,7 @@
+
diff --git a/Vanara.sln b/Vanara.sln
index 5c77af1f..663256b6 100644
--- a/Vanara.sln
+++ b/Vanara.sln
@@ -239,6 +239,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.DbgHelp", "P
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbgHelp", "UnitTests\PInvoke\DbgHelp\DbgHelp.csproj", "{F2C94926-224F-43AB-B351-C20C9B2D8656}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vanara.PInvoke.P2P", "PInvoke\P2P\Vanara.PInvoke.P2P.csproj", "{200D7E57-452A-4A43-A96D-386F7C49E7BA}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "P2P", "UnitTests\PInvoke\P2P\P2P.csproj", "{BBA10B94-658F-4BD7-A3DD-AA39CDF9A68D}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -765,6 +769,16 @@ Global
{F2C94926-224F-43AB-B351-C20C9B2D8656}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2C94926-224F-43AB-B351-C20C9B2D8656}.DebugNoTests|Any CPU.ActiveCfg = Debug|Any CPU
{F2C94926-224F-43AB-B351-C20C9B2D8656}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {200D7E57-452A-4A43-A96D-386F7C49E7BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {200D7E57-452A-4A43-A96D-386F7C49E7BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {200D7E57-452A-4A43-A96D-386F7C49E7BA}.DebugNoTests|Any CPU.ActiveCfg = Debug|Any CPU
+ {200D7E57-452A-4A43-A96D-386F7C49E7BA}.DebugNoTests|Any CPU.Build.0 = Debug|Any CPU
+ {200D7E57-452A-4A43-A96D-386F7C49E7BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {200D7E57-452A-4A43-A96D-386F7C49E7BA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BBA10B94-658F-4BD7-A3DD-AA39CDF9A68D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BBA10B94-658F-4BD7-A3DD-AA39CDF9A68D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BBA10B94-658F-4BD7-A3DD-AA39CDF9A68D}.DebugNoTests|Any CPU.ActiveCfg = Debug|Any CPU
+ {BBA10B94-658F-4BD7-A3DD-AA39CDF9A68D}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -867,6 +881,8 @@ Global
{E753F3A4-2A0B-49E2-9611-4F35534B5F72} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
{69604ECE-B123-4328-BEC3-996CCF22DB90} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
{F2C94926-224F-43AB-B351-C20C9B2D8656} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
+ {200D7E57-452A-4A43-A96D-386F7C49E7BA} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
+ {BBA10B94-658F-4BD7-A3DD-AA39CDF9A68D} = {385CAD2D-0A5E-4F80-927B-D5499D126B90}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {543FAC75-2AF1-4EF1-9609-B242B63FEED4}