From 005c158ecc5b799e10c217ec67506bd91ef88968 Mon Sep 17 00:00:00 2001 From: dahall Date: Fri, 28 Aug 2020 16:49:21 -0600 Subject: [PATCH] More P2P changes/additions --- PInvoke/P2P/P2P.Collab.cs | 16 ++++++++-------- PInvoke/P2P/P2P.Group.cs | 24 +++++++++++++++++++++++- PInvoke/P2P/P2P.cs | 10 ++++++++++ 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/PInvoke/P2P/P2P.Collab.cs b/PInvoke/P2P/P2P.Collab.cs index b7e54cb1..2e5a670e 100644 --- a/PInvoke/P2P/P2P.Collab.cs +++ b/PInvoke/P2P/P2P.Collab.cs @@ -1797,7 +1797,7 @@ namespace Vanara.PInvoke // *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); + public static extern HRESULT PeerCollabRegisterEvent(HANDLE hEvent, uint cEventRegistration, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] PEER_COLLAB_EVENT_REGISTRATION[] pEventRegistrations, out SafeCollabHPEEREVENT phPeerEvent); /// The PeerCollabSetEndpointName function sets the name of the current endpoint used by the peer application. /// @@ -2374,22 +2374,22 @@ namespace Vanara.PInvoke } /// Provides a for that is disposed using . - public class SafeHPEEREVENT : SafeHANDLE + public class SafeCollabHPEEREVENT : SafeHANDLE { - /// Initializes a new instance of the class and assigns an existing handle. + /// 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) { } + public SafeCollabHPEEREVENT(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } - /// Initializes a new instance of the class. - private SafeHPEEREVENT() : base() { } + /// Initializes a new instance of the class. + private SafeCollabHPEEREVENT() : base() { } - /// Performs an implicit conversion from to . + /// Performs an implicit conversion from to . /// The safe handle instance. /// The result of the conversion. - public static implicit operator HPEEREVENT(SafeHPEEREVENT h) => h.handle; + public static implicit operator HPEEREVENT(SafeCollabHPEEREVENT h) => h.handle; /// protected override bool InternalReleaseHandle() => PeerCollabUnregisterEvent(handle).Succeeded; diff --git a/PInvoke/P2P/P2P.Group.cs b/PInvoke/P2P/P2P.Group.cs index 1d804a39..9404447a 100644 --- a/PInvoke/P2P/P2P.Group.cs +++ b/PInvoke/P2P/P2P.Group.cs @@ -2017,7 +2017,7 @@ namespace Vanara.PInvoke [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); + [In, MarshalAs(UnmanagedType.LPArray)] PEER_GROUP_EVENT_REGISTRATION[] pEventRegistrations, out SafeGroupHPEEREVENT phPeerEvent); /// /// The PeerGroupSearchRecords function searches the local peer group database for records that match the supplied criteria. @@ -2510,5 +2510,27 @@ namespace Vanara.PInvoke /// public IntPtr DangerousGetHandle() => handle; } + + /// Provides a for that is disposed using . + public class SafeGroupHPEEREVENT : 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 SafeGroupHPEEREVENT(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + + /// Initializes a new instance of the class. + private SafeGroupHPEEREVENT() : base() { } + + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator HPEEREVENT(SafeGroupHPEEREVENT h) => h.handle; + + /// + protected override bool InternalReleaseHandle() => PeerGroupUnregisterEvent(handle).Succeeded; + } } } \ No newline at end of file diff --git a/PInvoke/P2P/P2P.cs b/PInvoke/P2P/P2P.cs index 4a4097e8..34c69388 100644 --- a/PInvoke/P2P/P2P.cs +++ b/PInvoke/P2P/P2P.cs @@ -12,6 +12,16 @@ namespace Vanara.PInvoke private const string Lib_P2P = "P2P.dll"; private const string Lib_P2PGraph = "p2pgraph.dll"; + /// + public static readonly Guid PEER_GROUP_ROLE_ADMIN = new Guid(0x04387127, 0xaa56, 0x450a, 0x8c, 0xe5, 0x4f, 0x56, 0x5c, 0x67, 0x90, 0xf4); + /// + public static readonly Guid PEER_GROUP_ROLE_MEMBER = new Guid(0xf12dc4c7, 0x0857, 0x4ca0, 0x93, 0xfc, 0xb1, 0xbb, 0x19, 0xa3, 0xd8, 0xc2); + /// + public static readonly Guid PEER_GROUP_ROLE_INVITING_MEMBER = new Guid(0x4370fd89, 0xdc18, 0x4cfb, 0x8d, 0xbf, 0x98, 0x53, 0xa8, 0xa9, 0xf9, 0x05); + /// + public static readonly Guid PEER_COLLAB_OBJECTID_USER_PICTURE = new Guid(0xdd15f41f, 0xfc4e, 0x4922, 0xb0, 0x35, 0x4c, 0x06, 0xa7, 0x54, 0xd0, 0x1d); + + /// The PEER_APPLICATION_REGISTRATION_TYPE enumeration defines the set of peer application registration flags. /// ///