diff --git a/PInvoke/PeerDist/PeerDist.cs b/PInvoke/PeerDist/PeerDist.cs
new file mode 100644
index 00000000..a6771f1e
--- /dev/null
+++ b/PInvoke/PeerDist/PeerDist.cs
@@ -0,0 +1,2077 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+namespace Vanara.PInvoke
+{
+ /// Items from the PeerDist.dll
+ public static partial class PeerDist
+ {
+ private const string Lib_PeerDist = "PeerDist.dll";
+
+ ///
+ public const uint PEERDIST_READ_TIMEOUT_DEFAULT = 0xfffffffe;
+ ///
+ public const uint PEERDIST_READ_TIMEOUT_LOCAL_CACHE_ONLY = 0;
+ ///
+ public const uint PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION = 2;
+ ///
+ public const uint PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION_1 = 1;
+ ///
+ public const uint PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION_2 = 2;
+
+ /// The PEERDIST_CLIENT_INFO_BY_HANDLE_CLASS enumeration defines the possible client information values.
+ ///
+ /// A value from this enumeration is passed to thePeerDistClientGetInformationByHandle function as the PeerDistClientInfoClass parameter.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/ne-peerdist-peerdist_client_info_by_handle_class typedef enum
+ // _PEERDIST_CLIENT_INFO_BY_HANDLE_CLASS { PeerDistClientBasicInfo, MaximumPeerDistClientInfoByHandlesClass }
+ // PEERDIST_CLIENT_INFO_BY_HANDLE_CLASS, *PPEERDIST_CLIENT_INFO_BY_HANDLE_CLASS;
+ [PInvokeData("peerdist.h", MSDNShortId = "NE:peerdist._PEERDIST_CLIENT_INFO_BY_HANDLE_CLASS")]
+ public enum PEERDIST_CLIENT_INFO_BY_HANDLE_CLASS
+ {
+ /// Indicates the information to retrieve is a PEERDIST_CLIENT_BASIC_INFO structure.
+ PeerDistClientBasicInfo,
+
+ ///
+ /// The maximum value for the enumeration that is used for error checking. This value should not be sent to the
+ /// PeerDistClientGetInformationByHandle function.
+ ///
+ MaximumPeerDistClientInfoByHandlesClass,
+ }
+
+ /// The PEERDIST_STATUS enumeration defines the possible status values of the Peer Distribution service.
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/ne-peerdist-peerdist_status typedef enum { PEERDIST_STATUS_DISABLED,
+ // PEERDIST_STATUS_UNAVAILABLE, PEERDIST_STATUS_AVAILABLE } PEERDIST_STATUS;
+ [PInvokeData("peerdist.h", MSDNShortId = "NE:peerdist.__unnamed_enum_0")]
+ public enum PEERDIST_STATUS
+ {
+ /// The service is disabled by Group Policy or according to configuration parameters.
+ PEERDIST_STATUS_DISABLED,
+
+ /// The service is not ready to process the request.
+ PEERDIST_STATUS_UNAVAILABLE,
+
+ /// The Peer Distribution service is available and ready to process requests.
+ PEERDIST_STATUS_AVAILABLE,
+ }
+
+ ///
+ /// The PeerDistClientAddContentInformation function adds the content information associated with a content handle opened by PeerDistClientOpenContent.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// A PEERDIST_CONTENT_HANDLE opened by PeerDistClientOpenContent.
+ /// Number of bytes in the pBuffer array.
+ ///
+ /// Pointer to the buffer that contains the content information. This buffer must remain valid for the duration of the add
+ /// operation. The caller must not use this buffer until the add operation is completed.
+ ///
+ ///
+ /// Pointer to an OVERLAPPED structure. The Internal member of OVERLAPPED structure contains the completion status of the
+ /// asynchronous operation. The Offset and OffsetHigh are reserved and must be 0.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_IO_PENDING. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// In order to retrieve content data from Peer Distribution service the client must add content information that it received from
+ /// the content server by calling the PeerDistClientAddContentInformation function. When all content information data has
+ /// been added, the PeerDistClientCompleteContentInformation function must be called. Once
+ /// PeerDistClientCompleteContentInformation is complete, the client can call PeerDistClientStreamRead or
+ /// PeerDistClientBlockRead to retrieve the data from the Peer Distribution system.
+ ///
+ ///
+ /// When calling this function multiple times on a single content handle, the caller must wait for each operation to complete before
+ /// the next call is made.
+ ///
+ ///
+ /// An application is not limited to adding content information with a single PeerDistClientAddContentInformation API call,
+ /// as it is possible to add portions of that content information as it is made available. When more content information is
+ /// available, the application can again call PeerDistClientAddContentInformation. When the application is done adding the
+ /// entire content information, it must then call PeerDistClientCompleteContentInformation.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistclientaddcontentinformation DWORD
+ // PeerDistClientAddContentInformation( PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle, DWORD
+ // cbNumberOfBytes, PBYTE pBuffer, LPOVERLAPPED lpOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistClientAddContentInformation")]
+ public static unsafe extern Win32Error PeerDistClientAddContentInformation(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle,
+ uint cbNumberOfBytes, [In] IntPtr pBuffer, [In] NativeOverlapped* lpOverlapped);
+
+ ///
+ /// The PeerDistClientAddData function is used to supply content to the local cache. Typically this is done when data could
+ /// not be found on the local network as indicated when either PeerDistClientBlockRead or PeerDistClientStreamRead complete with
+ /// ERROR_TIMEOUT or PEERDIST_ERROR_MISSING_DATA.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// A PEERDIST_CONTENT_HANDLE returned by PeerDistClientOpenContent.
+ /// The number of bytes to be added to the local cache.
+ ///
+ /// Pointer to the buffer that contains the data to be added to the local cache. This buffer must remain valid for the duration of
+ /// the add operation. The caller must not use this buffer until the add operation is completed.
+ ///
+ ///
+ /// Pointer to an OVERLAPPED structure. The byte offset from the beginning of content, at which this data is being added, is
+ /// specified by setting the Offset and OffsetHigh members of the OVERLAPPED structure. The OffsetHigh member
+ /// MUST be set to the higher 32 bits of the byte offset and the Offset member MUST be set to the lower 32 bits of the byte offset.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_IO_PENDING. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist or hContent handle is invalid.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The data that has been added with this function and passed verification is available to other peers or hosted cache for
+ /// download. The Peer Distribution service stores this data in its local cache.
+ ///
+ ///
+ /// If the API completes with PEERDIST_ERROR_OUT_OF_BOUNDS, this indicates that the offset specified in the overlapped
+ /// structure is beyond the end of the content.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistclientadddata DWORD PeerDistClientAddData(
+ // PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle, DWORD cbNumberOfBytes, PBYTE pBuffer, LPOVERLAPPED
+ // lpOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistClientAddData")]
+ public static unsafe extern Win32Error PeerDistClientAddData(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle, uint cbNumberOfBytes,
+ [In] IntPtr pBuffer, [In] NativeOverlapped* lpOverlapped);
+
+ /// The PeerDistClientBlockRead function reads content data blocks.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// A content handle opened by PeerDistClientOpenContent function call.
+ ///
+ /// The maximum number of bytes to read. If the cbMaxNumberOfBytesToRead is equal to 0, it indicates that the
+ /// PeerDistClientBlockRead function is querying the length of available consecutive content byes in the local cache at the
+ /// current block read offset. The query will neither download content from the peers, nor return the count of bytes present in the
+ /// peer cache.
+ ///
+ ///
+ /// Pointer to the buffer that receives the data from the local cache. This buffer must remain valid for the duration of the read
+ /// operation. The caller must not use this buffer until the read operation is completed. If the cbMaxNumberOfBytesToRead argument
+ /// is equal to 0, the pBuffer parameter can be NULL
+ ///
+ ///
+ /// Timeout value for the read, in milliseconds. There are two special values that may be specified:
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEERDIST_READ_TIMEOUT_LOCAL_CACHE_ONLY
+ /// Specifies that a read should not cause any additional network traffic by contacting peers or a Hosted Cache.
+ ///
+ /// -
+ /// PEERDIST_READ_TIMEOUT_DEFAULT
+ /// Specifies the default timeout of 5 seconds.
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to an OVERLAPPED structure. The start offset for read is specified by setting the Offset and OffsetHigh
+ /// members of the OVERLAPPED structure. The OffsetHigh member should be set to the higher 32 bits of the start offset and
+ /// the Offset member should be set to the lower 32 bits of the start offset.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_IO_PENDING. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist or hContent handle is invalid.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// PeerDistClientBlockRead queues the read and immediately returns to the caller. As a result, multiple reads can be issued
+ /// simultaneously. PeerDistClientBlockRead will complete a read as soon as any data is available and will not wait for the
+ /// buffer to fill completely.
+ ///
+ ///
+ /// If the PeerDistClientBlockRead function operation completes successfully, the Offset and OffsetHigh fields
+ /// of the OVERLAPPED structure will be populated with the ULONGLONG offset at which the read started. The OffsetHigh member
+ /// will be set to the higher 32 bits of the offset and the Offset member will be set to the lower 32 bits of the offset.
+ /// GetOverlappedResult will populate lpNumberOfBytesTransferred with the number of bytes transferred. In the event the caller is
+ /// using a completion port to process Peer Distribution API completions then the lpNumberOfBytes argument of
+ /// GetQueuedCompletionStatus will be populated with the number of bytes transferred.
+ ///
+ ///
+ /// If the cbMaxNumberOfBytesToRead argument is equal to 0, and the PeerDistClientBlockRead function completes successfully,
+ /// the number of bytes transferred (obtained via either GetQueuedCompletionStatus or GetOverlappedResult) will contain the actual
+ /// length of content available in the local cache.
+ ///
+ ///
+ /// When this API completes with error values PEERDIST_ERROR_MISSING_DATA or ERROR_TIMEOUT, the Offset and
+ /// OffsetHigh fields of the OVERLAPPED structure specify the ULONGLONG offset at which the missing data range begins.
+ /// The OffsetHigh member will be set to the higher 32 bits of the offset and the Offset member will be set to the lower 32 bits of
+ /// the offset. This missing data range is the start offset (relative to start of the content) and length, in bytes, which needs to
+ /// be retrieved from an alternate source, like the original content server. In order to allow the Peer Distribution service to
+ /// satisfy the same read in the future, add this data to the local cache by calling PeerDistClientAddData. The length of the
+ /// missing data range is specified by the number of bytes transferred (obtained via GetQueuedCompletionStatus or GetOverlappedResult).
+ ///
+ ///
+ /// It is important to note that the missing data range can start at any offset in the content and be any length up to the end of
+ /// the content. In the event the content information passed to PeerDistClientAddContentInformation was generated in response to a
+ /// range request, then the missing data range will be constrained to the range request bounds. This occurs when the call to
+ /// PeerDistServerOpenContentInformation on the content server specified an offset and a length which was a sub-range of the content
+ /// as a whole. A completion with ERROR_NO_MORE in this case indicates that the read offset is outside of the sub-range of
+ /// the content.
+ ///
+ /// Range Requests
+ ///
+ /// If a client is interested in only a portion of the original content, a range request can be used to retrieve that portion. A
+ /// range request contains an offset and length of the original content. The size of the content information is directly
+ /// proportional to the size of the content requested.
+ ///
+ ///
+ /// PeerDistServerOpenContentInformation supports generating content information for a range request via the ullContentOffset and
+ /// cbContentLength parameters. The ullContentOffset parameter represents the offset in the original content where the range begins
+ /// and cbContentLength represents the length of the range.
+ ///
+ ///
+ /// Once a client obtains content information representing a particular content range, that content information works seamlessly
+ /// with the PeerDistClientOpenContent, PeerDistClientAddContentInformation and PeerDistClientCompleteContentInformation APIs. The
+ /// content information can be passed to PeerDistServerOpenContentInformation and will associate the PEERDIST_CONTENT_HANDLE
+ /// with the content range. PeerDistClientStreamRead is constrained by the ullContentOffset offset and cbContentLength length
+ /// specified in the server side call to PeerDistServerRetrieveContentInformation. PeerDistClientStreamRead will begin at
+ /// ullContentOffset and will complete with the error code PEERDIST_ERROR_NO_MORE when the end of the content range is
+ /// reached at ullContentOffset + cbContentLength. PeerDistClientBlockRead will complete with the error code
+ /// PEERDIST_ERROR_NO_MORE if the offset specified in the OVERLAPPED parameter is less than ullContentOffset or greater than
+ /// ullContentOffset + cbContentLength. PeerDistClientStreamRead and PeerDistClientBlockRead both limit the amount of
+ /// missing data reported to the content range specified in the content information associated with the
+ /// PEERDIST_CONTENT_HANDLE. For example, if the content information represents only the first half of the content, missing
+ /// data will be limited to the first half of the content. In all other respects, PeerDistClientBlockRead and
+ /// PeerDistClientStreamRead work with content ranges in exactly the same manner in which they work with the content as a whole.
+ ///
+ ///
+ /// A client can use PeerDistClientStreamRead or PeerDistClientBlockRead to retrieve the content from the offset specified by
+ /// the ullContentOffset up to the length specified by cbContentLength in the PeerDistServerRetrieveContentInformation call. Both
+ /// PeerDistClientStreamRead and PeerDistClientBlockRead will complete with PEERDIST_ERROR_NO_MORE if the
+ /// client tries to read beyond the range specified by the ullContentOffset and cbContentLength. Additionally,
+ /// PeerDistClientBlockRead will also complete with the error code PEERDIST_ERROR_NO_MORE if the offset specified in
+ /// the OVERLAPPED parameter is less than ullContentOffset
+ ///
+ ///
+ /// If the read cannot not be completed from either the local cache or the peer cache, both PeerDistClientStreamRead and
+ /// PeerDistClientBlockRead will report PEERDIST_ERROR_MISSING_DATA. When using the ranged content information,
+ /// PeerDistClientStreamRead will report a missing data from the start offset of the range up to the end of the range.
+ /// PeerDistClientBlockRead will report missing data from start offset of the range up to the end of the range.
+ ///
+ ///
+ /// PeerDistClientAddData allows content data to be added even if it lies outside the content range. This extended data will be
+ /// validated after the corresponding content information has been added to the local cache. Once validated, it becomes available to
+ /// peers. In other words, if a client adds only content information for the first half of content, PeerDistClientAddData
+ /// still allows the client to add data for the entire content. However, the second half of the content will not be validated until
+ /// the corresponding content information for the second half has been added. No other Peer Distribution APIs are affected by range requests.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistclientblockread DWORD PeerDistClientBlockRead(
+ // PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle, DWORD cbMaxNumberOfBytes, PBYTE pBuffer, DWORD
+ // dwTimeoutInMilliseconds, LPOVERLAPPED lpOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistClientBlockRead")]
+ public static unsafe extern Win32Error PeerDistClientBlockRead(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle, uint cbMaxNumberOfBytes,
+ [Out] IntPtr pBuffer, uint dwTimeoutInMilliseconds, [In] NativeOverlapped* lpOverlapped);
+
+ ///
+ /// The PeerDistClientCancelAsyncOperation function cancels asynchronous operation associated with an OVERLAPPED structure
+ /// and the content handle returned by PeerDistClientOpenContent.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// A content handle opened by PeerDistClientOpenContent function call.
+ ///
+ /// Pointer to an OVERLAPPED structure that contains the canceling asynchronous operation data. If the pointer is NULL all
+ /// asynchronous operations for specified content handle will be canceled.
+ ///
+ ///
+ ///
+ /// The function will return ERROR_SUCCESS value if the operation associated with the specified OVERLAPPED structure is
+ /// successfully canceled. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ /// -
+ /// PEERDIST_ERROR_OPERATION_NOT_FOUND
+ /// The operation associated with the specified OVERLAPPED structure cannot be found.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This function will synchronously cancel the operation, but will not return until the cancellation result is posted to the
+ /// completion port or wait event is set to the signaled state. Any threads in waiting can receive the completion notice for the
+ /// operation before or after the PeerDistClientCancelAsyncOperation function returns.
+ ///
+ ///
+ /// This function does not guarantee that the operation will complete as canceled. The cancellation result will be posted only if no
+ /// other results have been posted.
+ ///
+ /// To confirm successfully canceled operations, a call should be made to GetOverlappedResult with an expected return of FALSE.
+ ///
+ /// Additionally, calling GetLastError immediately after a successful PeerDistClientCancelAsyncOperation will return the
+ /// ERROR_OPERATION_ABORTED error code.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistclientcancelasyncoperation DWORD
+ // PeerDistClientCancelAsyncOperation( PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle, LPOVERLAPPED
+ // pOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistClientCancelAsyncOperation")]
+ public static unsafe extern Win32Error PeerDistClientCancelAsyncOperation(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle,
+ [In] NativeOverlapped* pOverlapped);
+
+ /// The PeerDistClientCloseContent function closes the content handle opened by PeerDistClientOpenContent.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// A PEERDIST_CONTENT_HANDLE opened by PeerDistClientOpenContent.
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist or hContent handle is invalid.
+ ///
+ ///
+ ///
+ ///
+ /// This function will cancel all pending asynchronous operations associated with the provided hContentHandle.
+ /// All handles opened by the PeerDistClientOpenContent function must be closed by PeerDistClientCloseContent.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistclientclosecontent DWORD
+ // PeerDistClientCloseContent( PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistClientCloseContent")]
+ public static extern Win32Error PeerDistClientCloseContent(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle);
+
+ /// The PeerDistClientCompleteContentInformation function completes the process of adding the content information.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// A PEERDIST_CONTENT_HANDLE returned by PeerDistClientOpenContent.
+ /// Pointer to an OVERLAPPED structure.
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_IO_PENDING. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ /// Upon completion of this function, a client can call PeerDistClientStreamRead or PeerDistClientBlockRead to retrieve the data
+ /// from the Peer Distribution system.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistclientcompletecontentinformation DWORD
+ // PeerDistClientCompleteContentInformation( PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle,
+ // LPOVERLAPPED lpOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistClientCompleteContentInformation")]
+ public static unsafe extern Win32Error PeerDistClientCompleteContentInformation(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle,
+ [In] NativeOverlapped* lpOverlapped);
+
+ /// The PEERDIST_CONTENT_TAG.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ ///
+ /// Pointer to a PEERDIST_CONTENT_TAG structure that contains the tag supplied when PeerDistClientOpenContent is called.
+ ///
+ ///
+ /// A handle to the completion port that can be used for retrieving the completion notification of the asynchronous function. To
+ /// create a completion port, use the CreateIoCompletionPort function. This parameter can be NULL.
+ ///
+ ///
+ /// Value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function. This parameter is ignored
+ /// when hCompletionPort is NULL.
+ ///
+ ///
+ /// Pointer to an OVERLAPPED structure. Offset and OffsetHigh are reserved and must be zero.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_IO_PENDING. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ /// The pContentTag is a client supplied tag passed to PeerDistClientOpenContent, which labels the content added by the client. This
+ /// tag is used by the API to selectively flush content from the Peer Distribution cache.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistclientflushcontent DWORD
+ // PeerDistClientFlushContent( PEERDIST_INSTANCE_HANDLE hPeerDist, PCPEERDIST_CONTENT_TAG pContentTag, HANDLE hCompletionPort,
+ // ULONG_PTR ulCompletionKey, LPOVERLAPPED lpOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistClientFlushContent")]
+ public static unsafe extern Win32Error PeerDistClientFlushContent(PEERDIST_INSTANCE_HANDLE hPeerDist, in PEERDIST_CONTENT_TAG pContentTag,
+ [In, Optional] HANDLE hCompletionPort, [In, Optional] UIntPtr ulCompletionKey, [In] NativeOverlapped* lpOverlapped);
+
+ ///
+ /// The PeerDistClientGetInformationByHandle function retrieves additional information from the Peer Distribution service for
+ /// a specific content handle.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by the PeerDistStartup function.
+ /// A PEERDIST_CONTENT_HANDLE returned by the PeerDistClientOpenContent function.
+ ///
+ /// A value from the PEERDIST_CLIENT_INFO_BY_HANDLE_CLASS enumeration that indicates the information to retrieve.
+ ///
+ /// The size, in bytes, of the buffer for the lpInformation parameter.
+ ///
+ /// A buffer for the returned information. The format of this information depends on the value of the PeerDistClientInfoClass parameter.
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS.
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistclientgetinformationbyhandle DWORD
+ // PeerDistClientGetInformationByHandle( PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle,
+ // PEERDIST_CLIENT_INFO_BY_HANDLE_CLASS PeerDistClientInfoClass, DWORD dwBufferSize, LPVOID lpInformation );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistClientGetInformationByHandle")]
+ public static extern Win32Error PeerDistClientGetInformationByHandle(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle,
+ PEERDIST_CLIENT_INFO_BY_HANDLE_CLASS PeerDistClientInfoClass, uint dwBufferSize, [Out] IntPtr lpInformation);
+
+ ///
+ /// The PeerDistClientOpenContent function opens and returns a PEERDIST_CONTENT_HANDLE. The client uses the content handle to
+ /// retrieve data from the Peer Distribution service.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ ///
+ /// Pointer to a PEERDIST_CONTENT_TAG structure that contains a 16 byte client specified identifier. This parameter is used in
+ /// conjunction with the PeerDistClientFlushContent function.
+ ///
+ ///
+ /// A handle to the completion port that can be used for retrieving the completion notification of the asynchronous function. To
+ /// create a completion port, use the CreateIoCompletionPort function This parameter can be NULL.
+ ///
+ ///
+ /// Value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function. This parameter is ignored
+ /// when hCompletionPort is NULL.
+ ///
+ ///
+ /// A pointer to a variable that receives the PEERDIST_CONTENT_HANDLE used to retrieve or add data.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Client must call the PeerDistClientOpenContent function to obtain a PEERDIST_CONTENT_HANDLE handle that later can
+ /// be used in the following functions:
+ ///
+ ///
+ /// -
+ /// PeerDistClientAddContentInformation
+ ///
+ /// -
+ /// PeerDistClientCompleteContentInformation
+ ///
+ /// -
+ /// PeerDistClientBlockRead
+ ///
+ /// -
+ /// PeerDistClientStreamRead
+ ///
+ /// -
+ /// PeerDistClientAddData
+ ///
+ ///
+ ///
+ /// If an optional completion port handle is specified, it is used for posting the completion results of above listed asynchronous functions.
+ ///
+ /// The handle returned by PeerDistClientOpenContent function call must be closed by PeerDistClientCloseContent function.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistclientopencontent DWORD
+ // PeerDistClientOpenContent( PEERDIST_INSTANCE_HANDLE hPeerDist, PCPEERDIST_CONTENT_TAG pContentTag, HANDLE hCompletionPort,
+ // ULONG_PTR ulCompletionKey, PPEERDIST_CONTENT_HANDLE phContentHandle );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistClientOpenContent")]
+ public static extern Win32Error PeerDistClientOpenContent(PEERDIST_INSTANCE_HANDLE hPeerDist, in PEERDIST_CONTENT_TAG pContentTag,
+ [In, Optional] HANDLE hCompletionPort, [In, Optional] UIntPtr ulCompletionKey, out PEERDIST_CONTENT_HANDLE phContentHandle);
+
+ /// The PeerDistClientStreamRead reads a sequence of bytes from content stream.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// A content handle opened by the PeerDistClientOpenContent function call.
+ ///
+ /// The maximum number of bytes to read. If the cbMaxNumberOfBytesToRead is equal to 0, it indicates that the
+ /// PeerDistClientStreamRead function is querying the length of available consecutive content byes in the local cache at the
+ /// current stream read offset. The query will neither download content from the peers, nor return the count of bytes present in the
+ /// peer cache.
+ ///
+ ///
+ /// Pointer to the buffer that receives the data from the local cache. This buffer must remain valid for the duration of the read
+ /// operation. The caller must not use this buffer until the read operation is completed. If the cbMaxNumberOfBytesToRead argument
+ /// is equal to 0, the pBuffer parameter can be NULL.
+ ///
+ ///
+ /// Timeout value for the read, in milliseconds. There are two special values that may be specified:
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEERDIST_READ_TIMEOUT_LOCAL_CACHE_ONLY
+ /// Specifies that a read should not cause any additional network traffic by contacting peers or a Hosted Cache.
+ ///
+ /// -
+ /// PEERDIST_READ_TIMEOUT_DEFAULT
+ /// Specifies the default timeout of 5 seconds.
+ ///
+ ///
+ ///
+ ///
+ /// Pointer to an OVERLAPPED structure. Stream read does not allow the caller to specify the start Offset for the reading.
+ /// The next stream read offset is implicitly maintained per hContentHandle.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_IO_PENDING. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist or hContent handle is invalid.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// PeerDistClientStreamRead queues the read and immediately returns to the caller. As a result, multiple reads can be issued
+ /// simultaneously with the data buffers utilized in a first-in/first-out manner. PeerDistClientStreamRead will complete a
+ /// read as soon as any data is available and will not wait for the buffer to fill completely.
+ ///
+ ///
+ /// If the PeerDistClientStreamRead function operation completes successfully, the Offset and OffsetHigh fields
+ /// of the OVERLAPPED structure will be populated with the ULONGLONG offset at which the read started. The OffsetHigh member
+ /// will be set to the higher 32 bits of the offset and the Offset member will be set to the lower 32 bits of the offset.
+ /// GetOverlappedResult populates lpNumberOfBytesTransferred with the number of bytes transferred. In the event the caller is using
+ /// a completion port to process Peer Distribution API completions then the lpNumberOfBytes argument of GetQueuedCompletionStatus
+ /// will be populated with the number of bytes transferred. The stream offset will be advanced by the number of bytes reported as
+ /// read. To query the length of available content for content larger than 4GB, PeerDistClientBlockRead can be used with
+ /// cbMaxNumberOfBytesToRead equal to 0 and appropriate offsets.
+ ///
+ ///
+ /// If the API completes with the error value PEERDIST_ERROR_MISSING_DATA or ERROR_TIMEOUT, the Offset and
+ /// OffsetHigh fields of the OVERLAPPED structure specify the ULONGLONG offset at which the missing data range begins.
+ /// The OffsetHigh member will be set to the higher 32 bits of the offset and the Offset member will be set to the
+ /// lower 32 bits of the offset. This missing data range is the start offset (relative to start of the content) and length, in
+ /// bytes, which needs to be retrieved from an alternate source, like the original content server., In order to allow the Peer
+ /// Distribution service to satisfy the same read in the future, add this data to the local cache by calling PeerDistClientAddData.
+ /// The length of the missing data range is specified by the number of bytes transferred (obtained via GetQueuedCompletionStatus or
+ /// GetOverlappedResult). The stream offset is advanced by the number of bytes reported as the length of the missing data range.
+ ///
+ ///
+ /// If PeerDistClientStreamRead is called after the stream offset has advanced beyond the end of the content, the API will
+ /// complete with ERROR_NO_MORE.
+ ///
+ ///
+ /// It is important to note that the missing data range can start at any offset in the content and be any length up to the end of
+ /// the content. In the event the content information passed to PeerDistClientAddContentInformation was generated in response to a
+ /// range request, then the missing data range will be constrained to the range request bounds. This will happen when the call to
+ /// PeerDistServerOpenContentInformation on the content server specified an offset and a length which was a sub-range of the content
+ /// as a whole. A completion with ERROR_NO_MORE in this case indicates that the read offset is outside of the sub-range of
+ /// the content.
+ ///
+ /// Range Requests
+ ///
+ /// If a client is interested in only a portion of the original content, a range request can be used to retrieve that portion. A
+ /// range request contains an offset and length of the original content. The size of the content information is directly
+ /// proportional to the size of the content requested.
+ ///
+ ///
+ /// PeerDistServerOpenContentInformation supports generating content information for a range request via the ullContentOffset and
+ /// cbContentLength parameters. The ullContentOffset parameter represents the offset in the original content where the range begins
+ /// and cbContentLength represents the length of the range.
+ ///
+ ///
+ /// Once a client obtains content information representing a particular content range, that content information works seamlessly
+ /// with the PeerDistClientOpenContent, PeerDistClientAddContentInformation and PeerDistClientCompleteContentInformation APIs. The
+ /// content information can be passed to PeerDistServerOpenContentInformation and will associate the PEERDIST_CONTENT_HANDLE
+ /// with the content range. PeerDistClientStreamRead is constrained by the ullContentOffset offset and cbContentLength length
+ /// specified in the server side call to PeerDistServerRetrieveContentInformation. PeerDistClientStreamRead will begin at
+ /// ullContentOffset and will complete with the error code PEERDIST_ERROR_NO_MORE when the end of the content range is
+ /// reached at ullContentOffset + cbContentLength. PeerDistClientBlockRead will complete with the error code
+ /// PEERDIST_ERROR_NO_MORE if the offset specified in the OVERLAPPED parameter is less than ullContentOffset or greater than
+ /// ullContentOffset + cbContentLength. PeerDistClientStreamRead and PeerDistClientBlockRead both limit the amount of
+ /// missing data reported to the content range specified in the content information associated with the
+ /// PEERDIST_CONTENT_HANDLE. For example, if the content information represents only the first half of the content, missing
+ /// data will be limited to the first half of the content. In all other respects, PeerDistClientBlockRead and
+ /// PeerDistClientStreamRead work with content ranges in exactly the same manner in which they work with the content as a whole.
+ ///
+ ///
+ /// A client can use PeerDistClientStreamRead or PeerDistClientBlockRead to retrieve the content from the offset specified by
+ /// the ullContentOffset up to the length specified by cbContentLength in the PeerDistServerRetrieveContentInformation call. Both
+ /// PeerDistClientStreamRead and PeerDistClientBlockRead will complete with PEERDIST_ERROR_NO_MORE if the
+ /// client tries to read beyond the range specified by the ullContentOffset and cbContentLength. Additionally,
+ /// PeerDistClientBlockRead will also complete with the error code PEERDIST_ERROR_NO_MORE if the offset specified in
+ /// the OVERLAPPED parameter is less than ullContentOffset
+ ///
+ ///
+ /// If the read cannot not be completed from either the local cache or the peer cache, both PeerDistClientStreamRead and
+ /// PeerDistClientBlockRead will report PEERDIST_ERROR_MISSING_DATA. When using the ranged content information,
+ /// PeerDistClientStreamRead will report a missing data from the start offset of the range up to the end of the range.
+ /// PeerDistClientBlockRead will report missing data from start offset of the range up to the end of the range.
+ ///
+ ///
+ /// PeerDistClientAddData allows content data to be added even if it lies outside the content range. This extended data will be
+ /// validated after the corresponding content information has been added to the local cache. Once validated, it becomes available to
+ /// peers. In other words, if a client adds only content information for the first half of content, PeerDistClientAddData
+ /// still allows the client to add data for the entire content. However, the second half of the content will not be validated until
+ /// the corresponding content information for the second half has been added. No other Peer Distribution APIs are affected by range requests.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistclientstreamread DWORD PeerDistClientStreamRead(
+ // PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle, DWORD cbMaxNumberOfBytes, PBYTE pBuffer, DWORD
+ // dwTimeoutInMilliseconds, LPOVERLAPPED lpOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistClientStreamRead")]
+ public static unsafe extern Win32Error PeerDistClientStreamRead(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENT_HANDLE hContentHandle,
+ uint cbMaxNumberOfBytes, [Out, Optional] IntPtr pBuffer, uint dwTimeoutInMilliseconds, [In] NativeOverlapped* lpOverlapped);
+
+ ///
+ /// The PeerDistGetOverlappedResult function retrieves the results of asynchronous operations. This function replaces the
+ /// GetOverlappedResult function for Peer Distribution asynchronous operations.
+ ///
+ /// A pointer to an OVERLAPPED structure that was specified when the overlapped operation was started.
+ ///
+ /// A pointer to a variable that receives the number of bytes that were actually transferred by a read or write operation.
+ ///
+ ///
+ /// If this parameter is
+ /// true
+ /// , the function does not return until the operation has been completed. If this parameter is
+ /// false
+ /// and the operation is still pending, the function returns
+ /// false
+ /// .
+ ///
+ ///
+ /// Type: BOOL
+ ///
+ /// true
+ /// if the operation has completed.
+ /// false
+ /// if the bWait argument is
+ /// false
+ /// and the operation is still pending.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistgetoverlappedresult BOOL
+ // PeerDistGetOverlappedResult( LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistGetOverlappedResult")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static unsafe extern bool PeerDistGetOverlappedResult([In] NativeOverlapped* lpOverlapped, out uint lpNumberOfBytesTransferred, [MarshalAs(UnmanagedType.Bool)] bool bWait);
+
+ /// The PeerDistGetStatus function returns the current status of the Peer Distribution service.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ ///
+ /// A pointer to a PEERDIST_STATUS enumeration which upon operation success receives the current status of the Peer Distribution service.
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS.
+ ///
+ /// A Group Policy change can result in the Peer Distribution service moving to an available, unavailable, or disabled state.
+ /// Depending on the resultant state of this transition, the content, content information, or stream handles the caller has access
+ /// to may no longer function. If this is the case, the caller must explicitly close the handles by calling the appropriate Peer
+ /// Distribution API.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistgetstatus DWORD PeerDistGetStatus(
+ // PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_STATUS *pPeerDistStatus );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistGetStatus")]
+ public static extern Win32Error PeerDistGetStatus(PEERDIST_INSTANCE_HANDLE hPeerDist, out PEERDIST_STATUS pPeerDistStatus);
+
+ /// The PeerDistGetStatusEx function returns the current status and capabilities of the Peer Distribution service.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ ///
+ /// A pointer to a PEERDIST_STATUS_INFO structure that contains the current status and capabilities of the Peer Distribution service.
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS.
+ ///
+ /// A Group Policy change can result in the Peer Distribution service moving to an available, unavailable, or disabled state.
+ /// Depending on the resultant state of this transition, the content, content information, or stream handles the caller has access
+ /// to may no longer function. If this is the case, the caller must explicitly close the handles by calling the appropriate Peer
+ /// Distribution API.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistgetstatusex DWORD PeerDistGetStatusEx(
+ // PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_STATUS_INFO *pPeerDistStatus );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistGetStatusEx")]
+ public static extern Win32Error PeerDistGetStatusEx(PEERDIST_INSTANCE_HANDLE hPeerDist, ref PEERDIST_STATUS_INFO pPeerDistStatus);
+
+ ///
+ /// The PeerDistRegisterForStatusChangeNotification function requests the Peer Distribution service status change notification.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ ///
+ /// A handle to the completion port that can be used for retrieving the completion notification of the asynchronous function. To
+ /// create a completion port, use the CreateIoCompletionPort function. This parameter can be NULL.
+ ///
+ ///
+ /// Value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function. This parameter is ignored
+ /// when hCompletionPort is NULL.
+ ///
+ ///
+ /// Pointer to an OVERLAPPED structure. If the hEvent member of the structure is not NULL, it will be signaled via
+ /// SetEvent() used in order to signal the notification. This can occur even if the completion port is specified via the
+ /// hCompletionPort argument.
+ ///
+ ///
+ /// A pointer to a PEERDIST_STATUS enumeration that indicates the current status of the Peer Distribution service.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_IO_PENDING. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This function optionally registers a completion port and an OVERLAPPED structure for status change notification. Upon successful
+ /// completion, the pPeerDistStatus parameter will contain a valid PEERDIST_STATUS value.
+ ///
+ ///
+ /// Only one active registration for each session is allowed. The caller must register for notification each time after it signals.
+ /// The notification will be sent only if the current status is changed from the previous notification. After the first call of the
+ /// PeerDistRegisterForStatusChangeNotification function for the Peer Distribution session, the first notification will
+ /// trigger only if the status is no longer equal to PEERDIST_STATUS_DISABLED.
+ ///
+ ///
+ /// A Peer Distribution status change can result in the Peer Distribution service moving to an available, unavailable, or disabled
+ /// state. If the new status is disabled or unavailable, the content, content information, or stream handles the caller has access
+ /// to will no longer function. In this case, any API that uses these handles will fail with error PEERDIST_
+ /// ERROR_INVALIDATED. The caller must explicitly close the handles by calling the appropriate Peer Distribution API.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistregisterforstatuschangenotification DWORD
+ // PeerDistRegisterForStatusChangeNotification( PEERDIST_INSTANCE_HANDLE hPeerDist, HANDLE hCompletionPort, ULONG_PTR
+ // ulCompletionKey, LPOVERLAPPED lpOverlapped, PEERDIST_STATUS *pPeerDistStatus );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistRegisterForStatusChangeNotification")]
+ public static unsafe extern Win32Error PeerDistRegisterForStatusChangeNotification(PEERDIST_INSTANCE_HANDLE hPeerDist, [In, Optional] HANDLE hCompletionPort,
+ [In, Optional] UIntPtr ulCompletionKey, [In] NativeOverlapped* lpOverlapped, out PEERDIST_STATUS pPeerDistStatus);
+
+ ///
+ /// The PeerDistRegisterForStatusChangeNotificationEx function requests the Peer Distribution service status change notification.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ ///
+ /// A handle to the completion port that can be used for retrieving the completion notification of the asynchronous function. To
+ /// create a completion port, use the CreateIoCompletionPort function. This parameter can be NULL.
+ ///
+ ///
+ /// Value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function. This parameter is ignored
+ /// when hCompletionPort is NULL.
+ ///
+ ///
+ /// Pointer to an OVERLAPPED structure. If the hEvent member of the structure is not NULL, it will be signaled via
+ /// SetEvent() used in order to signal the notification. This can occur even if the completion port is specified via the
+ /// hCompletionPort argument.
+ ///
+ ///
+ /// A pointer to a PEERDIST_STATUS_INFO structure that contains the current status and capabilities of the Peer Distribution service.
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS.
+ ///
+ ///
+ /// This function optionally registers a completion port and an OVERLAPPED structure for status change notification. Upon successful
+ /// completion, the pPeerDistStatus parameter will contain a valid PEERDIST_STATUS value.
+ ///
+ ///
+ /// Only one active registration for each session is allowed. The caller must register for notification each time after it signals.
+ /// The notification will be sent only if the current status is changed from the previous notification. After the first call of the
+ /// PeerDistRegisterForStatusChangeNotification function for the Peer Distribution session, the first notification will trigger only
+ /// if the status is no longer equal to PEERDIST_STATUS_DISABLED.
+ ///
+ ///
+ /// A Peer Distribution status change can result in the Peer Distribution service moving to an available, unavailable, or disabled
+ /// state. If the new status is disabled or unavailable, the content, content information, or stream handles the caller has access
+ /// to will no longer function. In this case, any API that uses these handles will fail with error PEERDIST_
+ /// ERROR_INVALIDATED. The caller must explicitly close the handles by calling the appropriate Peer Distribution API.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistregisterforstatuschangenotificationex DWORD
+ // PeerDistRegisterForStatusChangeNotificationEx( PEERDIST_INSTANCE_HANDLE hPeerDist, HANDLE hCompletionPort, ULONG_PTR
+ // ulCompletionKey, LPOVERLAPPED lpOverlapped, PEERDIST_STATUS_INFO *pPeerDistStatus );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistRegisterForStatusChangeNotificationEx")]
+ public static unsafe extern Win32Error PeerDistRegisterForStatusChangeNotificationEx(PEERDIST_INSTANCE_HANDLE hPeerDist, [In, Optional] HANDLE hCompletionPort,
+ [In, Optional] UIntPtr ulCompletionKey, [In] NativeOverlapped* lpOverlapped, ref PEERDIST_STATUS_INFO pPeerDistStatus);
+
+ ///
+ /// The PeerDistServerCancelAsyncOperation function cancels the asynchronous operation associated with the content identifier
+ /// and OVERLAPPED structure.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// The length, in bytes, of the content identifier.
+ /// Pointer to an array that contains the content identifier.
+ /// Pointer to an OVERLAPPED structure that contains the canceling asynchronous operation data.
+ ///
+ ///
+ /// The function will return ERROR_SUCCESS value if the operation associated with OVERLAPPED structure is successfully
+ /// canceled. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ /// -
+ /// PEERDIST_ERROR_OPERATION_NOT_FOUND
+ /// The operation for OVERLAPPED structure cannot be found.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This function will synchronously cancel the operation, but will not return until the cancelation result is posted to the
+ /// completion port or wait event is set to the 'signaled' state. Any threads in waiting can receive the completion notice for the
+ /// operation before or after the PeerDistServerCancelAsyncOperation function returns.
+ ///
+ ///
+ /// This function does not guarantee that the operation will complete as canceled. The cancellation result will be posted only if no
+ /// other results have been posted.
+ ///
+ /// To confirm successfully canceled operations, a call should be made to GetOverlappedResult with an expected return of FALSE.
+ ///
+ /// Additionally, calling GetLastError immediately after a successful PeerDistServerCancelAsyncOperation will return the
+ /// ERROR_OPERATION_ABORTED error code.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistservercancelasyncoperation DWORD
+ // PeerDistServerCancelAsyncOperation( PEERDIST_INSTANCE_HANDLE hPeerDist, DWORD cbContentIdentifier, PBYTE pContentIdentifier,
+ // LPOVERLAPPED pOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerCancelAsyncOperation")]
+ public static unsafe extern Win32Error PeerDistServerCancelAsyncOperation(PEERDIST_INSTANCE_HANDLE hPeerDist, uint cbContentIdentifier,
+ [In] IntPtr pContentIdentifier, [In] NativeOverlapped* pOverlapped);
+
+ /// The PeerDistServerCloseContentInformation function closes the handle opened by PeerDistServerOpenContentInformation.
+ /// The PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// The handle returned by PeerDistServerOpenContentInformation.
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The provided hPeerDist or hContentInfo handles are invalid.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ ///
+ ///
+ ///
+ /// The PeerDistServerCloseContentInformation closes the PEERDIST_CONTENTINFO_HANDLE. Additionally, calling
+ /// PeerDistServerCloseContentInformation will cancel any pending operations associated with the PEERDIST_CONTENTINFO_HANDLE.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistserverclosecontentinformation DWORD
+ // PeerDistServerCloseContentInformation( PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENTINFO_HANDLE hContentInfo );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerCloseContentInformation")]
+ public static extern Win32Error PeerDistServerCloseContentInformation(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENTINFO_HANDLE hContentInfo);
+
+ /// The PeerDistServerCloseStreamHandle function closes a handle returned by PeerDistServerPublishStream.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// A PEERDIST_STREAM_HANDLE returned by PeerDistServerPublishStream.
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist or hStream handle is invalid
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The PeerDistServerCloseStreamHandle function call cancels all pending operations associated with hStream. To prevent
+ /// unintended cancellation of publication and closure of the stream handle, this function should be called after the completion of PeerDistServerPublishCompleteStream.
+ ///
+ /// PeerDistServerCloseStreamHandle does not remove the publication. In order to remove the publication, call PeerDistServerUnpublish.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistserverclosestreamhandle DWORD
+ // PeerDistServerCloseStreamHandle( PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_STREAM_HANDLE hStream );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerCloseStreamHandle")]
+ public static extern Win32Error PeerDistServerCloseStreamHandle(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_STREAM_HANDLE hStream);
+
+ ///
+ /// The PeerDistServerOpenContentInformation function opens a PEERDIST_CONTENTINFO_HANDLE. The client uses the handle
+ /// to retrieve content information.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// The length, in bytes, of the content identifier.
+ /// Pointer to a buffer that contains the content identifier.
+ ///
+ /// An offset from the beginning of the published content for which the content information handle is requested.
+ ///
+ ///
+ /// The length, in bytes, of the content (starting from the ullContentOffset) for which the content information is requested.
+ ///
+ ///
+ /// A handle to the completion port used for retrieving the completion notification of the asynchronous function. To create a
+ /// completion port, use the CreateIoCompletionPort function. This parameter can be NULL.
+ ///
+ ///
+ /// Value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function. This parameter is ignored
+ /// when hCompletionPort is NULL.
+ ///
+ /// A handle used to retrieve the content information.
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ /// -
+ /// PEERDIST_ERROR_NOT_FOUND
+ /// The specified content identifier data is not published.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// If function succeeds, the handle received by phContentInfo can be passed to the PeerDistServerRetrieveContentInformation
+ /// function to retrieve content information. The handle must be closed via the PeerDistServerCloseContentInformation function.
+ ///
+ /// If ullContentOffset and cbContentLength are both zero, then the content information for the whole content will be retrieved.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistserveropencontentinformation DWORD
+ // PeerDistServerOpenContentInformation( PEERDIST_INSTANCE_HANDLE hPeerDist, DWORD cbContentIdentifier, PBYTE pContentIdentifier,
+ // ULONGLONG ullContentOffset, ULONGLONG cbContentLength, HANDLE hCompletionPort, ULONG_PTR ulCompletionKey,
+ // PPEERDIST_CONTENTINFO_HANDLE phContentInfo );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerOpenContentInformation")]
+ public static extern Win32Error PeerDistServerOpenContentInformation(PEERDIST_INSTANCE_HANDLE hPeerDist, uint cbContentIdentifier,
+ [In] IntPtr pContentIdentifier, ulong ullContentOffset, ulong cbContentLength, [In, Optional] HANDLE hCompletionPort,
+ [In, Optional] UIntPtr ulCompletionKey, out PEERDIST_CONTENTINFO_HANDLE phContentInfo);
+
+ ///
+ /// The PeerDistServerOpenContentInformationEx function opens a PEERDIST_CONTENTINFO_HANDLE. The client uses the
+ /// handle to retrieve content information.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// The length, in bytes, of the content identifier.
+ /// Pointer to a buffer that contains the content identifier.
+ ///
+ /// An offset from the beginning of the published content for which the content information handle is requested.
+ ///
+ ///
+ /// The length, in bytes, of the content (starting from the ullContentOffset) for which the content information is requested.
+ ///
+ /// A PEER_RETRIEVAL_OPTIONS structure specifying additional options for retrieving content information.
+ ///
+ /// A handle to the completion port used for retrieving the completion notification of the asynchronous function. To create a
+ /// completion port, use the CreateIoCompletionPort function. This parameter can be NULL.
+ ///
+ ///
+ /// Value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function. This parameter is ignored
+ /// when hCompletionPort is NULL.
+ ///
+ /// A handle used to retrieve the content information.
+ /// If the function succeeds, the return value is ERROR_SUCCESS.
+ ///
+ ///
+ /// If function succeeds, the handle received by phContentInfo can be passed to the PeerDistServerRetrieveContentInformation
+ /// function to retrieve content information. The handle must be closed via the PeerDistServerCloseContentInformation function.
+ ///
+ /// If ullContentOffset and cbContentLength are both zero, then the content information for the whole content will be retrieved.
+ ///
+ /// The pRetrievalOptions parameter can be used to specify the range of content information versions that the requesting client is
+ /// configured to process. This enables the client to retrieve an applicable version of the content information structure.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistserveropencontentinformationex DWORD
+ // PeerDistServerOpenContentInformationEx( PEERDIST_INSTANCE_HANDLE hPeerDist, DWORD cbContentIdentifier, PBYTE pContentIdentifier,
+ // ULONGLONG ullContentOffset, ULONGLONG cbContentLength, PEERDIST_RETRIEVAL_OPTIONS *pRetrievalOptions, HANDLE hCompletionPort,
+ // ULONG_PTR ulCompletionKey, PPEERDIST_CONTENTINFO_HANDLE phContentInfo );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerOpenContentInformationEx")]
+ public static extern Win32Error PeerDistServerOpenContentInformationEx(PEERDIST_INSTANCE_HANDLE hPeerDist, uint cbContentIdentifier,
+ [In] IntPtr pContentIdentifier, ulong ullContentOffset, ulong cbContentLength, in PEERDIST_RETRIEVAL_OPTIONS pRetrievalOptions,
+ [In, Optional] HANDLE hCompletionPort, [In, Optional] UIntPtr ulCompletionKey, out PEERDIST_CONTENTINFO_HANDLE phContentInfo);
+
+ /// The PeerDistServerPublishAddToStream function adds data to the publishing stream.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// A PEERDIST_STREAM_HANDLE created by PeerDistServerPublishStream.
+ /// Number of bytes to be published.
+ ///
+ /// Pointer to the buffer that contains the data to be published. This buffer must remain valid for the duration of the add
+ /// operation. The caller must not use this buffer until the add operation is completed.
+ ///
+ ///
+ /// Pointer to an OVERLAPPED structure. The Offset and OffsetHigh members are reserved and must be zero.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_IO_PENDING. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist or hStream handle is invalid.
+ ///
+ /// -
+ /// ERROR_OPERATION_ABORTED
+ /// The operation was canceled.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ /// When calling this function multiple times on a single stream handle, the caller must wait for each operation to complete before
+ /// the next call is made.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistserverpublishaddtostream DWORD
+ // PeerDistServerPublishAddToStream( PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_STREAM_HANDLE hStream, DWORD cbNumberOfBytes,
+ // PBYTE pBuffer, LPOVERLAPPED lpOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerPublishAddToStream")]
+ public static unsafe extern Win32Error PeerDistServerPublishAddToStream(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_STREAM_HANDLE hStream,
+ uint cbNumberOfBytes, [In] IntPtr pBuffer, [In] NativeOverlapped* lpOverlapped);
+
+ /// The PeerDistServerPublishCompleteStream function completes the process of adding data to the stream.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// A PEERDIST_STREAM_HANDLE returned by PeerDistServerPublishStream.
+ ///
+ /// Pointer to an OVERLAPPED structure. The Offset and OffsetHigh are reserved and must be zero.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_IO_PENDING. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist or hStream handle is invalid
+ ///
+ /// -
+ /// ERROR_OPERATION_ABORTED
+ /// The operation was canceled.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Once this API completes successfully, PeerDistServerOpenContentInformation and PeerDistServerRetrieveContentInformation can be
+ /// used to retrieve content information.
+ ///
+ /// PeerDistServerPublishCompleteStream does not close hStream. In order to close hStream, call PeerDistServerCloseStreamHandle.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistserverpublishcompletestream DWORD
+ // PeerDistServerPublishCompleteStream( PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_STREAM_HANDLE hStream, LPOVERLAPPED
+ // lpOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerPublishCompleteStream")]
+ public static unsafe extern Win32Error PeerDistServerPublishCompleteStream(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_STREAM_HANDLE hStream,
+ [In] NativeOverlapped* lpOverlapped);
+
+ ///
+ /// The PeerDistServerPublishStream function initializes a new stream to be published to the Peer Distribution service.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// The length, in bytes, of the buffer that contains content identifier data.
+ /// A pointer to an array that contains a content identifier data.
+ ///
+ /// The length, in bytes, of the content to be published. This value can be 0 if the content length is not yet known. If a non-zero
+ /// argument is provided then it must match to the total data length added by PeerDistServerPublishAddToStream function calls.
+ ///
+ /// Pointer to a PEERDIST_PUBLICATION_OPTIONS structure that specifies content publishing rules.
+ ///
+ /// A handle to the completion port that can be used for retrieving the completion notification of the asynchronous function. To
+ /// create a completion port, use the CreateIoCompletionPort function. This parameter can be NULL.
+ ///
+ ///
+ /// Value returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function. This parameter is ignored when
+ /// hCompletionPort is NULL.
+ ///
+ ///
+ /// A pointer that receives a handle to the stream that is used to publish data into the Peer Distribution service.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The specified hPeerDist is invalid.
+ ///
+ /// -
+ /// PEERDIST_ERROR_ALREADY_EXISTS
+ /// The content identifier used for publication is already published.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// A content identifier is a user defined label for the content being published. This content identifier is used for
+ /// PeerDistServerOpenContentInformation, PeerDistServerUnpublish, and PeerDistServerCancelAsyncOperation calls.
+ ///
+ ///
+ /// The handle received by phStream can be used in PeerDistServerPublishAddToStream and PeerDistServerPublishCompleteStream to
+ /// publish data into the Peer Distribution service. This handle should be closed by PeerDistServerCloseStreamHandle.
+ ///
+ ///
+ /// A publication is accessible only to the User Account that originally published the content. If a different user calls
+ /// PeerDistServerPublishStream with the same content identifier, a separate publication will be created under the context of
+ /// that user.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistserverpublishstream DWORD
+ // PeerDistServerPublishStream( PEERDIST_INSTANCE_HANDLE hPeerDist, DWORD cbContentIdentifier, PBYTE pContentIdentifier, ULONGLONG
+ // cbContentLength, PCPEERDIST_PUBLICATION_OPTIONS pPublishOptions, HANDLE hCompletionPort, ULONG_PTR ulCompletionKey,
+ // PPEERDIST_STREAM_HANDLE phStream );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerPublishStream")]
+ public static extern Win32Error PeerDistServerPublishStream(PEERDIST_INSTANCE_HANDLE hPeerDist, uint cbContentIdentifier,
+ [In] IntPtr pContentIdentifier, ulong cbContentLength, in PEERDIST_PUBLICATION_OPTIONS pPublishOptions, [In, Optional] HANDLE hCompletionPort,
+ [In, Optional] UIntPtr ulCompletionKey, out PEERDIST_STREAM_HANDLE phStream);
+
+ ///
+ /// The PeerDistServerPublishStream function initializes a new stream to be published to the Peer Distribution service.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// The length, in bytes, of the buffer that contains content identifier data.
+ /// A pointer to an array that contains a content identifier data.
+ ///
+ /// The length, in bytes, of the content to be published. This value can be 0 if the content length is not yet known. If a non-zero
+ /// argument is provided then it must match to the total data length added by PeerDistServerPublishAddToStream function calls.
+ ///
+ /// Pointer to a PEERDIST_PUBLICATION_OPTIONS structure that specifies content publishing rules.
+ ///
+ /// A handle to the completion port that can be used for retrieving the completion notification of the asynchronous function. To
+ /// create a completion port, use the CreateIoCompletionPort function. This parameter can be NULL.
+ ///
+ ///
+ /// Value returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function. This parameter is ignored when
+ /// hCompletionPort is NULL.
+ ///
+ ///
+ /// A pointer that receives a handle to the stream that is used to publish data into the Peer Distribution service.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The specified hPeerDist is invalid.
+ ///
+ /// -
+ /// PEERDIST_ERROR_ALREADY_EXISTS
+ /// The content identifier used for publication is already published.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// A content identifier is a user defined label for the content being published. This content identifier is used for
+ /// PeerDistServerOpenContentInformation, PeerDistServerUnpublish, and PeerDistServerCancelAsyncOperation calls.
+ ///
+ ///
+ /// The handle received by phStream can be used in PeerDistServerPublishAddToStream and PeerDistServerPublishCompleteStream to
+ /// publish data into the Peer Distribution service. This handle should be closed by PeerDistServerCloseStreamHandle.
+ ///
+ ///
+ /// A publication is accessible only to the User Account that originally published the content. If a different user calls
+ /// PeerDistServerPublishStream with the same content identifier, a separate publication will be created under the context of
+ /// that user.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistserverpublishstream DWORD
+ // PeerDistServerPublishStream( PEERDIST_INSTANCE_HANDLE hPeerDist, DWORD cbContentIdentifier, PBYTE pContentIdentifier, ULONGLONG
+ // cbContentLength, PCPEERDIST_PUBLICATION_OPTIONS pPublishOptions, HANDLE hCompletionPort, ULONG_PTR ulCompletionKey,
+ // PPEERDIST_STREAM_HANDLE phStream );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerPublishStream")]
+ public static extern Win32Error PeerDistServerPublishStream(PEERDIST_INSTANCE_HANDLE hPeerDist, uint cbContentIdentifier,
+ [In] IntPtr pContentIdentifier, ulong cbContentLength, [In, Optional] IntPtr pPublishOptions, [In, Optional] HANDLE hCompletionPort,
+ [In, Optional] UIntPtr ulCompletionKey, out PEERDIST_STREAM_HANDLE phStream);
+
+ ///
+ /// The PeerDistServerRetrieveContentInformation function retrieves the encoded content information associated with a handle
+ /// returned by PeerDistServerOpenContentInformation.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// The handle returned by PeerDistServerOpenContentInformation.
+ /// The maximum number of bytes to read.
+ /// Pointer to the buffer that receives the content information data.
+ ///
+ /// Pointer to an OVERLAPPED structure. This function does not allow the caller to specify the start Offset in the content. The
+ /// offset is implicitly maintained per hContentInfo. The Offset and OffsetHigh are reserved and must be zero.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_IO_PENDING. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist or hContentInfo handle is invalid.
+ ///
+ /// -
+ /// PEERDIST_ERROR_NO_MORE
+ /// EOF on the content information has been reached.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// On the success of the PeerDistServerRetrieveContentInformation operation, the Offset and OffsetHigh fields
+ /// of the OVERLAPPED structure will be populated with the ULONGLONG offset in the content information that was retrieved.
+ /// The OffsetHigh member will be set to the higher 32 bits of the offset and the Offset member will be set to the
+ /// lower 32 bits of the offset.
+ ///
+ ///
+ /// GetOverlappedResult will populate lpNumberOfBytesTransferred with the number of bytes transferred. In the event the caller is
+ /// using a completion port to process Peer Distribution API completions, the lpNumberOfBytes argument of GetQueuedCompletionStatus
+ /// will be populated with the number of bytes transferred.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistserverretrievecontentinformation DWORD
+ // PeerDistServerRetrieveContentInformation( PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENTINFO_HANDLE hContentInfo, DWORD
+ // cbMaxNumberOfBytes, PBYTE pBuffer, LPOVERLAPPED lpOverlapped );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerRetrieveContentInformation")]
+ public static unsafe extern Win32Error PeerDistServerRetrieveContentInformation(PEERDIST_INSTANCE_HANDLE hPeerDist, PEERDIST_CONTENTINFO_HANDLE hContentInfo,
+ uint cbMaxNumberOfBytes, [Out] IntPtr pBuffer, [In] NativeOverlapped* lpOverlapped);
+
+ /// The PeerDistServerUnpublish function removes a publication created via PeerDistServerPublishStream.
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ /// The length, in bytes, of the content identifier.
+ /// Pointer to a buffer that contains the content identifier.
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ /// -
+ /// ERROR_ACCESS_DISABLED_BY_POLICY
+ /// The feature is disabled by Group Policy.
+ ///
+ /// -
+ /// PEERDIST_ERROR_SERVICE_UNAVAILABLE
+ /// The service is unavailable.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The PeerDistServerUnpublish function cancels all pending operations on unpublished content within the Peer Distribution
+ /// session that is associated with the specified hPeerDist. The client is still required to close previously opened handles on that
+ /// content with a call to PeerDistClientCloseContent.
+ ///
+ /// A publication is accessible only to the User Account that originally published the content.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistserverunpublish DWORD PeerDistServerUnpublish(
+ // PEERDIST_INSTANCE_HANDLE hPeerDist, DWORD cbContentIdentifier, PBYTE pContentIdentifier );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistServerUnpublish")]
+ public static extern Win32Error PeerDistServerUnpublish(PEERDIST_INSTANCE_HANDLE hPeerDist, uint cbContentIdentifier, [In] IntPtr pContentIdentifier);
+
+ ///
+ /// The PeerDistShutdown function releases resources allocated by a call to PeerDistStartup. Each handle returned by a
+ /// PeerDistStartup call must be closed by a matching call to PeerDistShutdown
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ ///
+ ///
+ ///
+ /// This function will remove all publications that were created with the specified hPeerDist handle. It is recommended that this
+ /// function is called after all pending operations have completed, as PeerDistShutdown cancel all pending Peer Distribution
+ /// client and server operations associated with the supplied PEERDIST_INSTANCE_HANDLE.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistshutdown DWORD PeerDistShutdown(
+ // PEERDIST_INSTANCE_HANDLE hPeerDist );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistShutdown")]
+ public static extern Win32Error PeerDistShutdown(PEERDIST_INSTANCE_HANDLE hPeerDist);
+
+ ///
+ /// The PeerDistStartup function creates a new Peer Distribution instance handle which must be passed to all other Peer
+ /// Distribution APIs.
+ ///
+ ///
+ /// Contains the minimum version of the Peer Distribution requested by the application. The high order byte specifies the minor
+ /// version number; the low order byte specifies the major version number.
+ ///
+ ///
+ /// A pointer to a PEERDIST_INSTANCE_HANDLE variable which upon success receives a newly created handle.
+ ///
+ ///
+ /// A pointer to a variable which, if not NULL, contains the maximum version number that is supported by the Peer
+ /// Distribution system. The high order byte specifies the minor version number; the low order byte specifies the major version number.
+ ///
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// PEERDIST_ERROR_VERSION_UNSUPPORTED
+ /// The requested version is not supported by client side DLL.
+ ///
+ ///
+ ///
+ ///
+ /// PeerDistStartup must be called before any other Peer Distribution functions. When no longer needed, the handle returned
+ /// by PeerDistStartup should be closed via a call to PeerDistShutdown.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdiststartup DWORD PeerDistStartup( DWORD
+ // dwVersionRequested, PPEERDIST_INSTANCE_HANDLE phPeerDist, PDWORD pdwSupportedVersion );
+ [DllImport(Lib_PeerDist, SetLastError = false, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistStartup")]
+ public static extern Win32Error PeerDistStartup(uint dwVersionRequested, out PEERDIST_INSTANCE_HANDLE phPeerDist, out uint pdwSupportedVersion);
+
+ ///
+ /// The PeerDistUnregisterForStatusChangeNotification function unregisters the status change notification for the session
+ /// associated with the specified handle.
+ ///
+ /// A PEERDIST_INSTANCE_HANDLE returned by PeerDistStartup.
+ ///
+ ///
+ /// If the function succeeds, the return value is ERROR_SUCCESS. Otherwise, the function may return one of the following values:
+ ///
+ ///
+ ///
+ /// Return code
+ /// Description
+ ///
+ /// -
+ /// ERROR_INVALID_PARAMETER
+ /// One or more parameters are invalid.
+ ///
+ /// -
+ /// ERROR_INVALID_HANDLE
+ /// The hPeerDist handle is invalid.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// This function cancels any registered notification previously set by a PeerDistRegisterForStatusChangeNotification function call.
+ ///
+ ///
+ /// To confirm successfully canceled operations, a call should be made to GetOverlappedResult using the OVERLAPPED structure
+ /// returned by GetQueuedCompletionStatus with an expected return of FALSE.
+ ///
+ ///
+ /// Additionally, calling GetLastError immediately after a successful PeerDistRegisterForStatusChangeNotification will return the
+ /// ERROR_OPERATION_ABORTED error code.
+ ///
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/nf-peerdist-peerdistunregisterforstatuschangenotification DWORD
+ // PeerDistUnregisterForStatusChangeNotification( PEERDIST_INSTANCE_HANDLE hPeerDist );
+ [DllImport(Lib_PeerDist, SetLastError = true, ExactSpelling = true)]
+ [PInvokeData("peerdist.h", MSDNShortId = "NF:peerdist.PeerDistUnregisterForStatusChangeNotification")]
+ public static extern Win32Error PeerDistUnregisterForStatusChangeNotification(PEERDIST_INSTANCE_HANDLE hPeerDist);
+
+ ///
+ /// The PEERDIST_CLIENT_BASIC_INFO structure indicates whether or not there are many clients simultaneously downloading the
+ /// same content.
+ ///
+ ///
+ ///
+ /// Thie PEERDIST_CLIENT_BASIC_INFO structure is retrieved from the PeerDistClientGetInformationHandle function with
+ /// PeerDistClientBasicInfo value specified for the PeerDistClientInfoClass parameter.
+ ///
+ /// If true, content that cannot be retrieved from the Peer Distribution APIs may soon be available for retrieval.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/ns-peerdist-peerdist_client_basic_info typedef struct
+ // _PEERDIST_CLIENT_BASIC_INFO { BOOL fFlashCrowd; } PEERDIST_CLIENT_BASIC_INFO, *PPEERDIST_CLIENT_BASIC_INFO;
+ [PInvokeData("peerdist.h", MSDNShortId = "NS:peerdist._PEERDIST_CLIENT_BASIC_INFO")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEERDIST_CLIENT_BASIC_INFO
+ {
+ ///
+ /// Indicates that a "flash crowd" situation has been detected, where many clients in the branch office are simultaneously
+ /// downloading the same content.
+ ///
+ [MarshalAs(UnmanagedType.Bool)]
+ public bool fFlashCrowd;
+ }
+
+ /// Provides a handle to peer distribution conent.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEERDIST_CONTENT_HANDLE : IHandle
+ {
+ private IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public PEERDIST_CONTENT_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static PEERDIST_CONTENT_HANDLE NULL => new PEERDIST_CONTENT_HANDLE(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(PEERDIST_CONTENT_HANDLE h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator PEERDIST_CONTENT_HANDLE(IntPtr h) => new PEERDIST_CONTENT_HANDLE(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(PEERDIST_CONTENT_HANDLE h1, PEERDIST_CONTENT_HANDLE h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(PEERDIST_CONTENT_HANDLE h1, PEERDIST_CONTENT_HANDLE h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is PEERDIST_CONTENT_HANDLE h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ ///
+ /// The PEERDIST_CONTENT_TAG structure contains a client supplied content tag as an input to the PeerDistClientOpenContent API.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/ns-peerdist-peerdist_content_tag typedef struct
+ // peerdist_content_tag_tag { BYTE Data[16]; } PEERDIST_CONTENT_TAG, *PPEERDIST_CONTENT_TAG;
+ [PInvokeData("peerdist.h", MSDNShortId = "NS:peerdist.peerdist_content_tag_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEERDIST_CONTENT_TAG
+ {
+ /// A 16 byte tag associated with the open content.
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
+ public byte[] Data;
+ }
+
+ /// Provides a handle to peer distribution content info.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEERDIST_CONTENTINFO_HANDLE : IHandle
+ {
+ private IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public PEERDIST_CONTENTINFO_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static PEERDIST_CONTENTINFO_HANDLE NULL => new PEERDIST_CONTENTINFO_HANDLE(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(PEERDIST_CONTENTINFO_HANDLE h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator PEERDIST_CONTENTINFO_HANDLE(IntPtr h) => new PEERDIST_CONTENTINFO_HANDLE(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(PEERDIST_CONTENTINFO_HANDLE h1, PEERDIST_CONTENTINFO_HANDLE h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(PEERDIST_CONTENTINFO_HANDLE h1, PEERDIST_CONTENTINFO_HANDLE h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is PEERDIST_CONTENTINFO_HANDLE h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ /// Provides a handle to a peer distribution instance.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEERDIST_INSTANCE_HANDLE : IHandle
+ {
+ private IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public PEERDIST_INSTANCE_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static PEERDIST_INSTANCE_HANDLE NULL => new PEERDIST_INSTANCE_HANDLE(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(PEERDIST_INSTANCE_HANDLE h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator PEERDIST_INSTANCE_HANDLE(IntPtr h) => new PEERDIST_INSTANCE_HANDLE(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(PEERDIST_INSTANCE_HANDLE h1, PEERDIST_INSTANCE_HANDLE h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(PEERDIST_INSTANCE_HANDLE h1, PEERDIST_INSTANCE_HANDLE h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is PEERDIST_INSTANCE_HANDLE h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+
+ ///
+ /// The PEERDIST_PUBLICATION_OPTIONS structure contains publication options, including the API version information and
+ /// possible option flags.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/ns-peerdist-peerdist_publication_options typedef struct
+ // peerdist_publication_options_tag { DWORD dwVersion; DWORD dwFlags; } PEERDIST_PUBLICATION_OPTIONS, *PPEERDIST_PUBLICATION_OPTIONS;
+ [PInvokeData("peerdist.h", MSDNShortId = "NS:peerdist.peerdist_publication_options_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEERDIST_PUBLICATION_OPTIONS
+ {
+ ///
+ /// The following possible values reflect the version number of the client:
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// 1
+ /// Version 1.0
+ ///
+ /// -
+ /// 2
+ /// Version 2.0
+ ///
+ ///
+ ///
+ public uint dwVersion;
+
+ /// Reserved.
+ public uint dwFlags;
+ }
+
+ /// The PEER_RETRIEVAL_OPTIONS structure contains version of the content information to retrieve.
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/ns-peerdist-peerdist_retrieval_options typedef struct
+ // peerdist_retrieval_options_tag { DWORD cbSize; DWORD dwContentInfoMinVersion; DWORD dwContentInfoMaxVersion; DWORD dwReserved; }
+ // PEERDIST_RETRIEVAL_OPTIONS, *PPEERDIST_RETRIEVAL_OPTIONS;
+ [PInvokeData("peerdist.h", MSDNShortId = "NS:peerdist.peerdist_retrieval_options_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEERDIST_RETRIEVAL_OPTIONS
+ {
+ /// Specifies the size of the input structure.
+ public uint cbSize;
+
+ ///
+ /// Specifies the minimum version of the content information to retrieve. Must be set to one of the following values:
+ /// PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION
+ /// PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION_1
+ /// PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION_2
+ ///
+ public uint dwContentInfoMinVersion;
+
+ ///
+ /// Specifies the maximum version of the content information to retrieve. Must be set to one of the following values:
+ /// PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION
+ /// PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION_1
+ /// PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION_2
+ ///
+ public uint dwContentInfoMaxVersion;
+
+ /// Reserved. The dwReserved member should be set to 0.
+ public uint dwReserved;
+ }
+
+ ///
+ /// The PEERDIST_STATUS_INFO structure contains information about the current status and capabilities of the BranchCache
+ /// service on the local computer.
+ ///
+ // https://docs.microsoft.com/en-us/windows/win32/api/peerdist/ns-peerdist-peerdist_status_info typedef struct
+ // peerdist_status_info_tag { DWORD cbSize; PEERDIST_STATUS status; DWORD dwMinVer; DWORD dwMaxVer; } PEERDIST_STATUS_INFO, *PPEERDIST_STATUS_INFO;
+ [PInvokeData("peerdist.h", MSDNShortId = "NS:peerdist.peerdist_status_info_tag")]
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEERDIST_STATUS_INFO
+ {
+ /// Size, in bytes, of the PEERDIST_STATUS_INFO structure.
+ public uint cbSize;
+
+ ///
+ /// Specifies the current status of the BranchCache service. This member should be one of following values defined in the
+ /// PEERDIST_STATUS enumeration.
+ ///
+ public PEERDIST_STATUS status;
+
+ ///
+ ///
+ /// Specifies the minimum version of the content information format supported by the BranchCache service on the local machine.
+ /// This member must be set to one of the following values.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION_1 1
+ /// Windows 7 compatible content information format.
+ ///
+ /// -
+ /// PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION_2 2
+ /// Windows 8 content information format.
+ ///
+ ///
+ ///
+ public uint dwMinVer;
+
+ ///
+ ///
+ /// Specifies the maximum version of the content information format supported by the BranchCache service on the local machine.
+ /// This member must be set to one of the following values.
+ ///
+ ///
+ ///
+ /// Value
+ /// Meaning
+ ///
+ /// -
+ /// PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION_1 1
+ /// Windows 7 compatible content information format.
+ ///
+ /// -
+ /// PEERDIST_RETRIEVAL_OPTIONS_CONTENTINFO_VERSION_2 2
+ /// Windows 8 content information format.
+ ///
+ ///
+ ///
+ public uint dwMaxVer;
+ }
+
+ /// Provides a handle to a peer distribution stream.
+ [StructLayout(LayoutKind.Sequential)]
+ public struct PEERDIST_STREAM_HANDLE : IHandle
+ {
+ private IntPtr handle;
+
+ /// Initializes a new instance of the struct.
+ /// An object that represents the pre-existing handle to use.
+ public PEERDIST_STREAM_HANDLE(IntPtr preexistingHandle) => handle = preexistingHandle;
+
+ /// Returns an invalid handle by instantiating a object with .
+ public static PEERDIST_STREAM_HANDLE NULL => new PEERDIST_STREAM_HANDLE(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(PEERDIST_STREAM_HANDLE h) => h.handle;
+
+ /// Performs an implicit conversion from to .
+ /// The pointer to a handle.
+ /// The result of the conversion.
+ public static implicit operator PEERDIST_STREAM_HANDLE(IntPtr h) => new PEERDIST_STREAM_HANDLE(h);
+
+ /// Implements the operator !=.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator !=(PEERDIST_STREAM_HANDLE h1, PEERDIST_STREAM_HANDLE h2) => !(h1 == h2);
+
+ /// Implements the operator ==.
+ /// The first handle.
+ /// The second handle.
+ /// The result of the operator.
+ public static bool operator ==(PEERDIST_STREAM_HANDLE h1, PEERDIST_STREAM_HANDLE h2) => h1.Equals(h2);
+
+ ///
+ public override bool Equals(object obj) => obj is PEERDIST_STREAM_HANDLE h && handle == h.handle;
+
+ ///
+ public override int GetHashCode() => handle.GetHashCode();
+
+ ///
+ public IntPtr DangerousGetHandle() => handle;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PInvoke/PeerDist/Vanara.PInvoke.PeerDist.csproj b/PInvoke/PeerDist/Vanara.PInvoke.PeerDist.csproj
new file mode 100644
index 00000000..4216f53a
--- /dev/null
+++ b/PInvoke/PeerDist/Vanara.PInvoke.PeerDist.csproj
@@ -0,0 +1,73 @@
+
+
+
+ PeerDist.dll
+
+
+ PInvoke API (methods, structures and constants) imported from Windows PeerDist.dll.
+ $(AssemblyName)
+ net20;net35;net40;net45;netstandard2.0;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;netcoreapp3.1
+ Vanara.PInvoke.PeerDist
+ $(AssemblyName)
+ pinvoke;vanara;net-extensions;interop;PeerDist
+
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PInvoke/Shared/WinError/Win32Error.Values.cs b/PInvoke/Shared/WinError/Win32Error.Values.cs
index 14011b94..a8e7389f 100644
--- a/PInvoke/Shared/WinError/Win32Error.Values.cs
+++ b/PInvoke/Shared/WinError/Win32Error.Values.cs
@@ -9349,5 +9349,56 @@ namespace Vanara.PInvoke
/// A device which does not exist was specified.
public const uint ERROR_NO_SUCH_DEVICE = 433;
+
+ /// The version of the supplied content information is not supported.
+ public const uint PEERDIST_ERROR_CONTENTINFO_VERSION_UNSUPPORTED = 4050;
+
+ /// The supplied content information is malformed.
+ public const uint PEERDIST_ERROR_CANNOT_PARSE_CONTENTINFO = 4051;
+
+ /// The requested data cannot be found in local or peer caches.
+ public const uint PEERDIST_ERROR_MISSING_DATA = 4052;
+
+ /// No more data is available or required.
+ public const uint PEERDIST_ERROR_NO_MORE = 4053;
+
+ /// The supplied object has not been initialized.
+ public const uint PEERDIST_ERROR_NOT_INITIALIZED = 4054;
+
+ /// The supplied object has already been initialized.
+ public const uint PEERDIST_ERROR_ALREADY_INITIALIZED = 4055;
+
+ /// A shutdown operation is already in progress.
+ public const uint PEERDIST_ERROR_SHUTDOWN_IN_PROGRESS = 4056;
+
+ /// The supplied object has already been invalidated.
+ public const uint PEERDIST_ERROR_INVALIDATED = 4057;
+
+ /// An element already exists and was not replaced.
+ public const uint PEERDIST_ERROR_ALREADY_EXISTS = 4058;
+
+ /// Can not cancel the requested operation as it has already been completed.
+ public const uint PEERDIST_ERROR_OPERATION_NOTFOUND = 4059;
+
+ /// Can not perform the requested operation because it has already been carried out.
+ public const uint PEERDIST_ERROR_ALREADY_COMPLETED = 4060;
+
+ /// An operation accessed data beyond the bounds of valid data.
+ public const uint PEERDIST_ERROR_OUT_OF_BOUNDS = 4061;
+
+ /// The requested version is not supported.
+ public const uint PEERDIST_ERROR_VERSION_UNSUPPORTED = 4062;
+
+ /// A configuration value is invalid.
+ public const uint PEERDIST_ERROR_INVALID_CONFIGURATION = 4063;
+
+ /// The SKU is not licensed.
+ public const uint PEERDIST_ERROR_NOT_LICENSED = 4064;
+
+ /// PeerDist Service is still initializing and will be available shortly.
+ public const uint PEERDIST_ERROR_SERVICE_UNAVAILABLE = 4065;
+
+ /// Communication with one or more computers will be temporarily blocked due to recent errors.
+ public const uint PEERDIST_ERROR_TRUST_FAILURE = 4066;
}
-}
+}
\ No newline at end of file
diff --git a/Vanara.sln b/Vanara.sln
index bfc8202f..29bcb07a 100644
--- a/Vanara.sln
+++ b/Vanara.sln
@@ -243,6 +243,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vanara.PInvoke.P2P", "PInvo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "P2P", "UnitTests\PInvoke\P2P\P2P.csproj", "{BBA10B94-658F-4BD7-A3DD-AA39CDF9A68D}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vanara.PInvoke.PeerDist", "PInvoke\PeerDist\Vanara.PInvoke.PeerDist.csproj", "{3108565B-2F79-447B-9386-42203CD949A5}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -779,6 +781,12 @@ Global
{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
+ {3108565B-2F79-447B-9386-42203CD949A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3108565B-2F79-447B-9386-42203CD949A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3108565B-2F79-447B-9386-42203CD949A5}.DebugNoTests|Any CPU.ActiveCfg = Debug|Any CPU
+ {3108565B-2F79-447B-9386-42203CD949A5}.DebugNoTests|Any CPU.Build.0 = Debug|Any CPU
+ {3108565B-2F79-447B-9386-42203CD949A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3108565B-2F79-447B-9386-42203CD949A5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -883,6 +891,7 @@ Global
{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}
+ {3108565B-2F79-447B-9386-42203CD949A5} = {212ABBD0-B724-4CFA-9D6D-E3891547FA90}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {543FAC75-2AF1-4EF1-9609-B242B63FEED4}