namespace Vanara.PInvoke; public static partial class Shell32 { /// Flags used in IOperationsProgressDialog::StartProgressDialog // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-ioperationsprogressdialog-startprogressdialog [PInvokeData("shobjidl_core.h", MSDNShortId = "5d6f44e0-259f-42d3-9912-877d90f0e7fc")] [Flags] public enum OPPROGDLGF { /// Default operation. OPPROGDLG_DEFAULT = 0x00000000, /// Add a pause button (operation can be paused) OPPROGDLG_ENABLEPAUSE = 0x00000080, /// The operation can be undone in the dialog. (The Stop button becomes Undo) OPPROGDLG_ALLOWUNDO = 0x00000100, /// Don't display the path of source file in progress dialog OPPROGDLG_DONTDISPLAYSOURCEPATH = 0x00000200, /// Don't display the path of destination file in progress dialog OPPROGDLG_DONTDISPLAYDESTPATH = 0x00000400, /// deprecated - progress dialog no longer displays > 1 day estimates OPPROGDLG_NOMULTIDAYESTIMATES = 0x00000800, /// Don't display the location line in the progress dialog OPPROGDLG_DONTDISPLAYLOCATIONS = 0x00001000, } /// Flags used in IOperationsProgressDialog::SetMode [PInvokeData("shobjidl_core.h")] [Flags] public enum PDMODE { /// 0x00000000. Use the default progress dialog operations mode. PDM_DEFAULT = 0x00000000, /// 0x00000001. The operation is running. PDM_RUN = 0x00000001, /// 0x00000002. The operation is gathering data before it begins, such as calculating the predicted operation time. PDM_PREFLIGHT = 0x00000002, /// 0x00000004. The operation is rolling back due to an Undo command from the user. PDM_UNDOING = 0x00000004, /// 0x00000008. Error dialogs are blocking progress from continuing. PDM_ERRORSBLOCKING = 0x00000008, /// /// 0x00000010. The length of the operation is indeterminate. Do not show a timer and display the progress bar in marquee mode. /// PDM_INDETERMINATE = 0x00000010, } /// Provides operation status flags for IOperationsProgressDialog::GetOperationStatus // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/ne-shobjidl_core-pdopstatus typedef enum PDOPSTATUS { // PDOPS_RUNNING , PDOPS_PAUSED , PDOPS_CANCELLED , PDOPS_STOPPED , PDOPS_ERRORS } ; [PInvokeData("shobjidl_core.h", MSDNShortId = "f9fd5cbe-2cb7-4ae7-9cf2-f8545095eec8")] public enum PDOPSTATUS { /// Operation is running, no user intervention. PDOPS_RUNNING = 1, /// Operation has been paused by the user. PDOPS_PAUSED = 2, /// Operation has been canceled by the user - now go undo. PDOPS_CANCELLED = 3, /// Operation has been stopped by the user - terminate completely. PDOPS_STOPPED = 4, /// Operation has gone as far as it can go without throwing error dialogs. PDOPS_ERRORS = 5, } /// /// Describes an action being performed that requires progress to be shown to the user using an IActionProgress interface. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/ne-shobjidl_core-_spaction [PInvokeData("shobjidl_core.h", MSDNShortId = "fc5a0f96-e8c2-483f-86b0-d8c870a9f77a")] public enum SPACTION { /// No action is being performed. SPACTION_NONE, /// Files are being moved. SPACTION_MOVING, /// Files are being copied. SPACTION_COPYING, /// Files are being deleted. SPACTION_RECYCLING, /// A set of attributes are being applied to files. SPACTION_APPLYINGATTRIBS, /// A file is being downloaded from a remote source. SPACTION_DOWNLOADING, /// An Internet search is being performed. SPACTION_SEARCHING_INTERNET, /// A calculation is being performed. SPACTION_CALCULATING, /// A file is being uploaded to a remote source. SPACTION_UPLOADING, /// A local search is being performed. SPACTION_SEARCHING_FILES, /// Windows Vista and later. A deletion is being performed. SPACTION_DELETING, /// Windows Vista and later. A renaming action is being performed. SPACTION_RENAMING, /// Windows Vista and later. A formatting action is being performed. SPACTION_FORMATTING, /// Windows 7 and later. A copy or move action is being performed. SPACTION_COPY_MOVING, } /// /// Exposes methods for posting a cancel window message to the process thread from the Progress Dialog. /// /// This interface enables the progress dialog to post a thread message through PostThreadMessage to the worker thread to cancel its /// operations. The worker thread must periodically check the message queue through GetMessage, PeekMessage or MsgWaitForMultipleObjectsEx. /// /// /// The IIOCancelInformation::SetCancelInformation method tells the progress dialog which thread ID and what message to /// PostThreadMessage when the user clicks Cancel. A thread ID of "zero" disables the sending operation for the cancel message. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-iiocancelinformation [PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.IIOCancelInformation")] [ComImport, Guid("f5b0bf81-8cb5-4b1b-9449-1a159e0c733c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IIOCancelInformation { /// /// Sets information that is posted when a user selects Cancel from the progress UI. Allows the main object to tell the /// progress dialog thread about the process thread so that the progress dialog can send the process thread the message id when /// the user clicks Cancel. /// /// /// Type: DWORD /// The ID of the process thread to be canceled. /// /// /// Type: UINT /// The cancel message to be posted to the thread. /// /// /// When the user selects Cancel from the progress UI, the dwThreadID will cancel any pending or future input/output /// (I/O) requests. Also the uMsgCancel message, received from the progress dialog, will be posted to the thread to tell it to /// exit a wait state, if asynchronous I/O is pending. /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iiocancelinformation-setcancelinformation // HRESULT SetCancelInformation( DWORD dwThreadID, UINT uMsgCancel ); void SetCancelInformation(uint dwThreadID, uint uMsgCancel); /// /// Returns information that is posted when a user selects Cancel from the progress UI. The process thread uses this /// method to find out which message the progress dialog will send to the process thread when the user hits cancel. The process /// thread then listens for this message and does its own cleanup upon receipt. /// /// /// Type: DWORD* /// When this method returns, contains a pointer to the ID of the process thread. /// /// /// Type: UINT* /// /// When this method returns, contains a pointer to uMsgCancel that the process thread should post if the operation is canceled. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-iiocancelinformation-getcancelinformation // HRESULT GetCancelInformation( DWORD *pdwThreadID, UINT *puMsgCancel ); void GetCancelInformation(out uint pdwThreadID, out uint puMsgCancel); } /// Exposes methods to get, set, and query a progress dialog. // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ioperationsprogressdialog [PInvokeData("shobjidl_core.h", MSDNShortId = "0d95f407-0e09-441d-b9e2-665995ea1362")] [ComImport, Guid("0C9FB851-E5C9-43EB-A370-F0677B13874C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(ProgressDialog))] public interface IOperationsProgressDialog { /// /// Starts the specified progress dialog. /// /// /// Type: HWND /// A handle to the parent window. /// /// /// /// /// The progress dialog should be created on a separate thread than the file operation on which the dialog is reporting. If the /// dialog is running in the same thread as the file operation, progress messages are, at best, only sent as resources allow. /// Progress messages on the same thread as the file operation might not be sent at all. /// /// /// Once IOperationsProgressDialog::StartProgressDialog is called, that instance of the CLSID_ProgressDialog /// object cannot be accessed by , , or /// . Although QueryInterface can be used to access these interfaces, most of their methods cannot be /// invoked. IOperationsProgressDialog is the interface used to display the new progress dialog for the Windows Vista and later /// operations engine. /// /// void StartProgressDialog([In] HWND hwndOwner, [In] OPPROGDLGF flags); /// Stops current progress dialog. void StopProgressDialog(); /// /// Sets which progress dialog operation is occurring, and whether we are in pre-flight or undo mode. /// /// /// Type: SPACTION /// Specifies operation. See SPACTION. /// void SetOperation([In] SPACTION action); /// /// Sets progress dialog operations mode. /// /// /// Type: PDMODE /// Specifies the operation mode. The following are valid values. /// PDM_DEFAULT /// 0x00000000. Use the default progress dialog operations mode. /// PDM_RUN /// 0x00000001. The operation is running. /// PDM_PREFLIGHT /// 0x00000002. The operation is gathering data before it begins, such as calculating the predicted operation time. /// PDM_UNDOING /// 0x00000004. The operation is rolling back due to an Undo command from the user. /// PDM_ERRORSBLOCKING /// 0x00000008. Error dialogs are blocking progress from continuing. /// PDM_INDETERMINATE /// /// 0x00000010. The length of the operation is indeterminate. Do not show a timer and display the progress bar in marquee mode. /// /// void SetMode([In] PDMODE mode); /// /// Updates the current progress dialog, as specified. /// /// /// Type: ULONGLONG /// Current points, used for showing progress in points. /// /// /// Type: ULONGLONG /// Total points, used for showing progress in points. /// /// /// Type: ULONGLONG /// Current size in bytes, used for showing progress in bytes. /// /// /// Type: ULONGLONG /// Total size in bytes, used for showing progress in bytes. /// /// /// Type: ULONGLONG /// Current items, used for showing progress in items. /// /// /// Type: ULONGLONG /// Specifies total items, used for showing progress in items. /// void UpdateProgress(ulong ullPointsCurrent, ulong ullPointsTotal, ulong ullSizeCurrent, ulong ullSizeTotal, ulong ullItemsCurrent, ulong ullItemsTotal); /// /// Called to specify the text elements stating the source and target in the current progress dialog. /// /// /// Type: IShellItem* /// A pointer to an IShellItem that represents the source Shell item. /// /// /// Type: IShellItem* /// A pointer to an IShellItem that represents the target Shell item. /// /// /// Type: IShellItem* /// /// A pointer to an IShellItem that represents the item currently being operated on by the operation engine. This parameter is /// only used in Windows 7 and later. In earlier versions, this parameter should be NULL. /// /// void UpdateLocations([In] IShellItem psiSource, [In] IShellItem psiTarget, [In, Optional] IShellItem? psiItem); /// /// Resets progress dialog timer to 0. /// void ResetTimer(); /// /// Pauses progress dialog timer. /// void PauseTimer(); /// /// Resumes progress dialog timer. /// void ResumeTimer(); /// Gets elapsed and remaining time for progress dialog. /// /// Type: ULONGLONG* /// A pointer to the elapsed time in milliseconds. /// /// /// Type: ULONGLONG* /// A pointer to the remaining time in milliseconds. /// void GetMilliseconds(out ulong pullElapsed, out ulong pullRemaining); /// /// Gets operation status for progress dialog. /// /// /// Type: PDOPSTATUS* /// Contains pointer to the operation status. See PDOPSTATUS. /// PDOPSTATUS GetOperationStatus(); } }