diff --git a/PInvoke/P2P/P2P.Collab.cs b/PInvoke/P2P/P2P.Collab.cs index b1fd87cc..9c4be611 100644 --- a/PInvoke/P2P/P2P.Collab.cs +++ b/PInvoke/P2P/P2P.Collab.cs @@ -47,7 +47,9 @@ namespace Vanara.PInvoke // 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); + public static extern HRESULT PeerCollabAddContact([MarshalAs(UnmanagedType.LPWStr)] string pwzContactData, + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_CONTACT ppContact); + out SafePeerData ppContact); /// /// The PeerCollabAsyncInviteContact function sends an invitation to a trusted peer contact to join the sender's peer @@ -1263,7 +1265,8 @@ namespace Vanara.PInvoke // 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); + public static extern HRESULT PeerCollabGetAppLaunchInfo(out SafePeerData ppLaunchInfo); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_APP_LAUNCH_INFO ppLaunchInfo); /// The PeerCollabGetApplicationRegistrationInfo function obtains application-specific registration information. /// Pointer to the GUID value that represents a particular peer's application registration flags. @@ -1313,7 +1316,8 @@ namespace Vanara.PInvoke [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)] [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetApplicationRegistrationInfo")] public static extern HRESULT PeerCollabGetApplicationRegistrationInfo(in Guid pApplicationId, PEER_APPLICATION_REGISTRATION_TYPE registrationType, - [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_APPLICATION_REGISTRATION_INFO ppApplication); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_APPLICATION_REGISTRATION_INFO ppApplication); + out SafePeerData ppApplication); /// The PeerCollabGetContact function obtains the information for a peer contact given the peer name of the contact. /// @@ -1353,7 +1357,8 @@ namespace Vanara.PInvoke [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)] [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetContact")] public static extern HRESULT PeerCollabGetContact([MarshalAs(UnmanagedType.LPWStr)] string pwzPeerName, - [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_CONTACT ppContact); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_CONTACT ppContact); + out SafePeerData ppContact); /// /// The PeerCollabGetEndpointName function retrieves the name of the current endpoint of the calling peer, as previously set @@ -1428,7 +1433,8 @@ namespace Vanara.PInvoke [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)] [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetEventData")] public static extern HRESULT PeerCollabGetEventData(HPEEREVENT hPeerEvent, - [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_COLLAB_EVENT_DATA ppEventData); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_COLLAB_EVENT_DATA ppEventData); + out SafePeerData ppEventData); /// /// The PeerCollabGetInvitationResponse function obtains the response from a peer previously invited to join a peer @@ -1484,7 +1490,8 @@ namespace Vanara.PInvoke [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)] [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetInvitationResponse")] public static extern HRESULT PeerCollabGetInvitationResponse(HANDLE hInvitation, - [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_RESPONSE ppInvitationResponse); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_RESPONSE ppInvitationResponse); + out SafePeerData ppInvitationResponse); /// /// The PeerCollabGetPresenceInfo function retrieves the presence information for the endpoint associated with a specific contact. @@ -1540,7 +1547,8 @@ namespace Vanara.PInvoke [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)] [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabGetPresenceInfo")] public static extern HRESULT PeerCollabGetPresenceInfo(in PEER_ENDPOINT pcEndpoint, - [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_PRESENCE_INFO ppPresenceInfo); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_PRESENCE_INFO ppPresenceInfo); + out SafePeerData ppPresenceInfo); /// /// The PeerCollabGetSigninOptions function obtains the peer's current signed-in peer collaboration network presence options. @@ -1645,7 +1653,8 @@ namespace Vanara.PInvoke [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)] [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabInviteContact")] public static extern HRESULT PeerCollabInviteContact(in PEER_CONTACT pcContact, in PEER_ENDPOINT pcEndpoint, in PEER_INVITATION pcInvitation, - [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_RESPONSE ppResponse); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_RESPONSE ppResponse); + out SafePeerData ppResponse); /// /// The PeerCollabInviteEndpoint function sends an invitation to a specified peer endpoint to join the sender's peer @@ -1711,7 +1720,8 @@ namespace Vanara.PInvoke [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)] [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabInviteEndpoint")] public static extern HRESULT PeerCollabInviteEndpoint(in PEER_ENDPOINT pcEndpoint, in PEER_INVITATION pcInvitation, - [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_RESPONSE ppResponse); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_RESPONSE ppResponse); + out SafePeerData ppResponse); /// /// The PeerCollabParseContact function parses a Unicode string buffer containing contact XML data into a PEER_CONTACT data structure. @@ -1750,7 +1760,8 @@ namespace Vanara.PInvoke [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)] [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerCollabParseContact")] public static extern HRESULT PeerCollabParseContact([MarshalAs(UnmanagedType.LPWStr)] string pwzContactData, - [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_CONTACT ppContact); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_CONTACT ppContact); + out SafePeerData ppContact); /// The PeerCollabQueryContactData function retrieves the contact information for the supplied peer endpoint. /// @@ -1800,7 +1811,8 @@ namespace Vanara.PInvoke // 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); + 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. /// diff --git a/PInvoke/P2P/P2P.Funcs.cs b/PInvoke/P2P/P2P.Funcs.cs index 795a3932..4f08db3b 100644 --- a/PInvoke/P2P/P2P.Funcs.cs +++ b/PInvoke/P2P/P2P.Funcs.cs @@ -456,7 +456,8 @@ namespace Vanara.PInvoke [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)] [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerPnrpGetCloudInfo")] public static extern HRESULT PeerPnrpGetCloudInfo(out uint pcNumClouds, - [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_PNRP_CLOUD_INFO ppCloudInfo); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_PNRP_CLOUD_INFO ppCloudInfo); + out SafePeerData ppCloudInfo); /// /// The PeerPnrpGetEndpoint function retrieves a peer endpoint address resolved during an asynchronous peer name resolution operation. @@ -506,7 +507,8 @@ namespace Vanara.PInvoke [DllImport(Lib_P2P, SetLastError = false, ExactSpelling = true)] [PInvokeData("p2p.h", MSDNShortId = "NF:p2p.PeerPnrpGetEndpoint")] public static extern HRESULT PeerPnrpGetEndpoint(HRESOLUTION hResolve, - [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_PNRP_ENDPOINT_INFO ppEndpoint); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_PNRP_ENDPOINT_INFO ppEndpoint); + out SafePeerData ppEndpoint); /// /// @@ -1070,6 +1072,12 @@ namespace Vanara.PInvoke /// protected SafePeerData(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } + /// + /// Marshals data from an unmanaged block of memory to a newly allocated managed object of the type specified by a generic type parameter. + /// + /// The type of the object to which the data is to be copied. This must be a structure. + public T ToStructure() where T : struct => handle.ToStructure(); + /// protected override bool InternalReleaseHandle() { PeerFreeData(handle); return true; } } @@ -1077,33 +1085,32 @@ namespace Vanara.PInvoke /// Provides a for an array that is disposed using . /// The type of the structure that can be enumerated. /// - public class SafePeerList : SafePeerData, IEnumerable where T : struct + public class SafePeerList : SafeHANDLE, IEnumerable where T : struct { private uint count = 0; - internal SafePeerList() : base() - { - } + internal SafePeerList() : base() { } internal SafePeerList(IntPtr preexistingHandle, uint cnt) : base(preexistingHandle, true) => count = cnt; /// Gets the items exposed by this list. /// The items. /// Object has been disposed - public IList Items => IsInvalid ? (new T[0]) : DangerousGetHandle().ToArray((int)count); + public IList Items => IsInvalid ? (new T[0]) : Array.ConvertAll(DangerousGetHandle().ToArray((int)count), p => p.ToStructure()); /// Returns an enumerator that iterates through the collection. /// A that can be used to iterate through the collection. public IEnumerator GetEnumerator() => Items.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// + protected override bool InternalReleaseHandle() { PeerFreeData(handle); return true; } } internal class PeerStringMarshaler : ICustomMarshaler { - internal PeerStringMarshaler() - { - } + internal PeerStringMarshaler() { } public static ICustomMarshaler GetInstance(string _) => new PeerStringMarshaler(); @@ -1130,7 +1137,7 @@ namespace Vanara.PInvoke public object MarshalNativeToManaged(IntPtr pNativeData) => Marshal.PtrToStringUni(pNativeData); } - internal class PeerStructMarshaler : ICustomMarshaler where T : struct + /*internal class PeerStructMarshaler : ICustomMarshaler where T : struct { internal PeerStructMarshaler() { @@ -1159,7 +1166,7 @@ namespace Vanara.PInvoke /// 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)); - } + }*/ /* PeerGraphAddRecord diff --git a/PInvoke/P2P/P2P.Group.cs b/PInvoke/P2P/P2P.Group.cs index d6dc600a..05f2d6b1 100644 --- a/PInvoke/P2P/P2P.Group.cs +++ b/PInvoke/P2P/P2P.Group.cs @@ -1194,7 +1194,8 @@ namespace Vanara.PInvoke [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); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_GROUP_EVENT_DATA ppEventData); + out SafePeerData ppEventData); /// The PeerGroupGetProperties function retrieves information on the properties of a specified group. /// @@ -1246,7 +1247,8 @@ namespace Vanara.PInvoke [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); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_GROUP_PROPERTIES ppProperties); + out SafePeerData ppProperties); /// The PeerGroupGetRecord function retrieves a specific group record. /// @@ -1301,7 +1303,8 @@ namespace Vanara.PInvoke [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); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_RECORD ppRecord); + out SafePeerData ppRecord); /// The PeerGroupGetStatus function retrieves the current status of a group. /// @@ -1898,7 +1901,8 @@ namespace Vanara.PInvoke [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); + //[Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(PeerStructMarshaler))] out PEER_INVITATION_INFO ppInvitationInfo); + out SafePeerData ppInvitationInfo); /// /// The PeerGroupPasswordJoin function prepares a peer with an invitation and the correct password to join a diff --git a/PInvoke/P2P/P2P.Identity.cs b/PInvoke/P2P/P2P.Identity.cs index 5c653e21..eb44d046 100644 --- a/PInvoke/P2P/P2P.Identity.cs +++ b/PInvoke/P2P/P2P.Identity.cs @@ -112,7 +112,7 @@ namespace Vanara.PInvoke // 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 SafePeerList PeerEnumGroups([MarshalAs(UnmanagedType.LPWStr)] string pwzIdentity) => + public static SafePeerList PeerEnumGroups(string pwzIdentity) => PeerEnum(() => { PeerEnumGroups(pwzIdentity, out var h).ThrowIfFailed(); return h; }); /// diff --git a/PInvoke/P2P/P2P.cs b/PInvoke/P2P/P2P.cs index 6ff81a4d..d60cb46b 100644 --- a/PInvoke/P2P/P2P.cs +++ b/PInvoke/P2P/P2P.cs @@ -289,16 +289,16 @@ namespace Vanara.PInvoke 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, + PEER_GROUP_EVENT_MEMBER_CHANGED = 8, /// /// 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_CONNECTION_FAILED = 10, /// - PEER_GROUP_EVENT_AUTHENTICATION_FAILED, + PEER_GROUP_EVENT_AUTHENTICATION_FAILED = 11, } /// The PEER_GROUP_ISSUE_CREDENTIAL_FLAGS are used to specify if user credentials are stored within a group. @@ -762,47 +762,47 @@ namespace Vanara.PInvoke /// /// A PEER_EVENT_WATCHLIST_CHANGED_DATA structure. This data structure is present when eventType is set to PEER_EVENT_WATCHLIST_CHANGED. /// - [FieldOffset(4)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] public PEER_EVENT_REQUEST_STATUS_CHANGED_DATA requestStatusChangedData; } @@ -1556,40 +1556,40 @@ namespace Vanara.PInvoke /// 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] public PEER_EVENT_SYNCHRONIZED_DATA synchronizedData; } @@ -1795,35 +1795,35 @@ namespace Vanara.PInvoke /// 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] 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)] + [FieldOffset(8)] public PEER_EVENT_MEMBER_CHANGE_DATA memberChangeData; /// @@ -1856,7 +1856,7 @@ namespace Vanara.PInvoke /// /// /// - [FieldOffset(4)] + [FieldOffset(8)] public HRESULT hrConnectionFailedReason; } @@ -2253,6 +2253,10 @@ namespace Vanara.PInvoke /// Specifies the friendly name of the peer identity or peer group. [MarshalAs(UnmanagedType.LPWStr)] public string pwzFriendlyName; + + /// Converts to string. + /// A that represents this instance. + public override string ToString() => pwzFriendlyName; } /// The PEER_NODE_INFO structure contains information that is specific to a particular node in a peer graph. diff --git a/Vanara.sln b/Vanara.sln index 663256b6..bfc8202f 100644 --- a/Vanara.sln +++ b/Vanara.sln @@ -239,7 +239,7 @@ 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}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "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