From f654f77e73f269a8bfed078c314be377a6366a51 Mon Sep 17 00:00:00 2001 From: David Hall Date: Sat, 21 Jul 2018 22:31:13 -0600 Subject: [PATCH] Added SHChangeNotify --- PInvoke/Shell32/ShlObj.cs | 185 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) diff --git a/PInvoke/Shell32/ShlObj.cs b/PInvoke/Shell32/ShlObj.cs index 083a623b..6bf8300d 100644 --- a/PInvoke/Shell32/ShlObj.cs +++ b/PInvoke/Shell32/ShlObj.cs @@ -106,6 +106,176 @@ namespace Vanara.PInvoke SHARD_SHELLITEM = 8 } + /// Events used in SHChangeNotify. + [PInvokeData("Shlobj_core.h")] + [Flags] + public enum SHCNE : uint + { + /// + /// The name of a nonfolder item has changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the + /// previous PIDL or name of the item. dwItem2 contains the new PIDL or name of the item. + /// + SHCNE_RENAMEITEM = 0x00000001, + /// + /// A nonfolder item has been created. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the item that was + /// created. dwItem2 is not used and should be NULL. + /// + SHCNE_CREATE = 0x00000002, + /// + /// A nonfolder item has been deleted. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the item that was + /// deleted. dwItem2 is not used and should be NULL. + /// + SHCNE_DELETE = 0x00000004, + /// + /// A folder has been created. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the folder that was + /// created. dwItem2 is not used and should be NULL. + /// + SHCNE_MKDIR = 0x00000008, + /// + /// A folder has been removed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the folder that was + /// removed. dwItem2 is not used and should be NULL. + /// + SHCNE_RMDIR = 0x00000010, + /// + /// Storage media has been inserted into a drive. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the + /// root of the drive that contains the new media. dwItem2 is not used and should be NULL. + /// + SHCNE_MEDIAINSERTED = 0x00000020, + /// + /// Storage media has been removed from a drive. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the + /// root of the drive from which the media was removed. dwItem2 is not used and should be NULL. + /// + SHCNE_MEDIAREMOVED = 0x00000040, + /// + /// A drive has been removed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the root of the drive that + /// was removed. dwItem2 is not used and should be NULL. + /// + SHCNE_DRIVEREMOVED = 0x00000080, + /// + /// A drive has been added. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the root of the drive that + /// was added. dwItem2 is not used and should be NULL. + /// + SHCNE_DRIVEADD = 0x00000100, + /// + /// A folder on the local computer is being shared via the network. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. + /// dwItem1 contains the folder that is being shared. dwItem2 is not used and should be NULL. + /// + SHCNE_NETSHARE = 0x00000200, + /// + /// A folder on the local computer is no longer being shared via the network. SHCNF_IDLIST or SHCNF_PATH must be specified in + /// uFlags. dwItem1 contains the folder that is no longer being shared. dwItem2 is not used and should be NULL. + /// + SHCNE_NETUNSHARE = 0x00000400, + /// + /// The attributes of an item or folder have changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains + /// the item or folder that has changed. dwItem2 is not used and should be NULL. + /// + SHCNE_ATTRIBUTES = 0x00000800, + /// + /// The contents of an existing folder have changed, but the folder still exists and has not been renamed. SHCNF_IDLIST or + /// SHCNF_PATH must be specified in uFlags. dwItem1 contains the folder that has changed. dwItem2 is not used and should be NULL. + /// If a folder has been created, deleted, or renamed, use SHCNE_MKDIR, SHCNE_RMDIR, or SHCNE_RENAMEFOLDER, respectively. + /// + SHCNE_UPDATEDIR = 0x00001000, + /// + /// An existing item (a folder or a nonfolder) has changed, but the item still exists and has not been renamed. SHCNF_IDLIST or + /// SHCNF_PATH must be specified in uFlags. dwItem1 contains the item that has changed. dwItem2 is not used and should be NULL. + /// If a nonfolder item has been created, deleted, or renamed, use SHCNE_CREATE, SHCNE_DELETE, or SHCNE_RENAMEITEM, respectively, instead. + /// + SHCNE_UPDATEITEM = 0x00002000, + /// + /// The computer has disconnected from a server. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the + /// server from which the computer was disconnected. dwItem2 is not used and should be NULL. + /// + SHCNE_SERVERDISCONNECT = 0x00004000, + /// + /// An image in the system image list has changed. SHCNF_DWORD must be specified in uFlags. dwItem2 contains the index in the + /// system image list that has changed. dwItem1 is not used and should be NULL. + /// + SHCNE_UPDATEIMAGE = 0x00008000, + /// + /// A drive has been added. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the root of the drive that + /// was added. dwItem2 is not used and should be NULL. + /// + SHCNE_DRIVEADDGUI = 0x00010000, + /// + /// The name of a folder has changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the previous PIDL + /// or name of the folder. dwItem2 contains the new PIDL or name of the folder. + /// + SHCNE_RENAMEFOLDER = 0x00020000, + /// + /// The amount of free space on a drive has changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the + /// root of the drive on which the free space changed. dwItem2 is not used and should be NULL. + /// + SHCNE_FREESPACE = 0x00040000, + /// Not currently used. + SHCNE_EXTENDED_EVENT = 0x04000000, + /// + /// A file type association has changed. SHCNF_IDLIST must be specified in the uFlags parameter. dwItem1 and dwItem2 are not used + /// and must be NULL. This event should also be sent for registered protocols. + /// + SHCNE_ASSOCCHANGED = 0x08000000, + /// All disk related events. + SHCNE_DISKEVENTS = 0x0002381F, + /// All global events. + SHCNE_GLOBALEVENTS = 0x0C0581E0, + /// All events. + SHCNE_ALLEVENTS = 0x7FFFFFFF, + /// + /// The presence of this flag indicates that the event was generated by an interrupt. It is stripped out before the clients of + /// SHCNNotify_ see it. + /// + SHCNE_INTERRUPT = 0x80000000, + } + + /// Flags used in SHChangeNotify. + [PInvokeData("Shlobj_core.h")] + [Flags] + public enum SHCNF : uint + { + /// + /// dwItem1 and dwItem2 are the addresses of ITEMIDLIST structures that represent the item(s) affected by the change. Each + /// ITEMIDLIST must be relative to the desktop folder. + /// + SHCNF_IDLIST = 0x0000, + /// + /// dwItem1 and dwItem2 are the addresses of null-terminated strings of maximum length MAX_PATH that contain the full path names + /// of the items affected by the change. + /// + SHCNF_PATHA = 0x0001, + /// + /// dwItem1 and dwItem2 are the addresses of null-terminated strings that represent the friendly names of the printer(s) affected + /// by the change. + /// + SHCNF_PRINTERA = 0x0002, + /// The dwItem1 and dwItem2 parameters are DWORD values. + SHCNF_DWORD = 0x0003, + /// + /// dwItem1 and dwItem2 are the addresses of null-terminated strings of maximum length MAX_PATH that contain the full path names + /// of the items affected by the change. + /// + SHCNF_PATHW = 0x0005, + /// + /// dwItem1 and dwItem2 are the addresses of null-terminated strings that represent the friendly names of the printer(s) affected + /// by the change. + /// + SHCNF_PRINTERW = 0x0006, + /// Indicates that a type is defined. + SHCNF_TYPE = 0x00FF, + /// + /// The function should not return until the notification has been delivered to all affected components. As this flag modifies + /// other data-type flags, it cannot be used by itself. + /// + SHCNF_FLUSH = 0x1000, + /// + /// The function should begin delivering notifications to all affected components but should return as soon as the notification + /// process has begun. As this flag modifies other data-type flags, it cannot by used by itself. This flag includes SHCNF_FLUSH. + /// + SHCNF_FLUSHNOWAIT = 0x3000, + /// Notify clients registered for all children. + SHCNF_NOTIFYRECURSIVE = 0x10000 + } + /// Receives a value that determines what type the item is in . [PInvokeData("Shlobj_core.h", MSDNShortId = "bb759775")] public enum SHDID @@ -341,6 +511,21 @@ namespace Vanara.PInvoke [PInvokeData("Shlobj.h", MSDNShortId = "bb762115")] public static extern PIDL SHBrowseForFolder(ref BROWSEINFO lpbi); + /// + /// Notifies the system of an event that an application has performed. An application should use this function if it performs an + /// action that may affect the Shell. + /// + /// + /// Describes the event that has occurred. Typically, only one event is specified at a time. If more than one event is specified, the + /// values contained in the dwItem1 and dwItem2 parameters must be the same, respectively, for all specified events. + /// + /// Flags that, when combined bitwise with SHCNF_TYPE, indicate the meaning of the dwItem1 and dwItem2 parameters. + /// Optional. First event-dependent value. + /// Optional. Second event-dependent value. + [DllImport(Lib.Shell32, ExactSpelling = true)] + [PInvokeData("Shlobj.h")] + public static extern void SHChangeNotify(SHCNE wEventId, SHCNF uFlags, [Optional] IntPtr dwItem1, [Optional] IntPtr dwItem2); + /// Creates a new instance of the default Shell folder view object (DefView). /// Pointer to a SFV_CREATE structure that describes the particulars used in creating this instance of the Shell folder view object. /// When this function returns successfully, contains an interface pointer to the new IShellView object. On failure, this value is NULL.