2 using System.Collections.Generic;
4 using System.Runtime.InteropServices;
9 #region Enums & Structs
11 #region enum HChangeNotifyEventID
13 /// Describes the event that has occurred.
14 /// Typically, only one event is specified at a time.
15 /// If more than one event is specified, the values contained
16 /// in the <i>dwItem1</i> and <i>dwItem2</i>
17 /// parameters must be the same, respectively, for all specified events.
18 /// This parameter can be one or more of the following values.
21 /// <para><b>Windows NT/2000/XP:</b> <i>dwItem2</i> contains the index
22 /// in the system image list that has changed.
23 /// <i>dwItem1</i> is not used and should be <see langword="null"/>.</para>
24 /// <para><b>Windows 95/98:</b> <i>dwItem1</i> contains the index
25 /// in the system image list that has changed.
26 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.</para>
29 enum HChangeNotifyEventID
32 /// All events have occurred.
34 SHCNE_ALLEVENTS = 0x7FFFFFFF,
37 /// A file type association has changed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/>
38 /// must be specified in the <i>uFlags</i> parameter.
39 /// <i>dwItem1</i> and <i>dwItem2</i> are not used and must be <see langword="null"/>.
41 SHCNE_ASSOCCHANGED = 0x08000000,
44 /// The attributes of an item or folder have changed.
45 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
46 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
47 /// <i>dwItem1</i> contains the item or folder that has changed.
48 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
50 SHCNE_ATTRIBUTES = 0x00000800,
53 /// A nonfolder item has been created.
54 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
55 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
56 /// <i>dwItem1</i> contains the item that was created.
57 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
59 SHCNE_CREATE = 0x00000002,
62 /// A nonfolder item has been deleted.
63 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
64 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
65 /// <i>dwItem1</i> contains the item that was deleted.
66 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
68 SHCNE_DELETE = 0x00000004,
71 /// A drive has been added.
72 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
73 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
74 /// <i>dwItem1</i> contains the root of the drive that was added.
75 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
77 SHCNE_DRIVEADD = 0x00000100,
80 /// A drive has been added and the Shell should create a new window for the drive.
81 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
82 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
83 /// <i>dwItem1</i> contains the root of the drive that was added.
84 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
86 SHCNE_DRIVEADDGUI = 0x00010000,
89 /// A drive has been removed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
90 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
91 /// <i>dwItem1</i> contains the root of the drive that was removed.
92 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
94 SHCNE_DRIVEREMOVED = 0x00000080,
97 /// Not currently used.
99 SHCNE_EXTENDED_EVENT = 0x04000000,
102 /// The amount of free space on a drive has changed.
103 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
104 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
105 /// <i>dwItem1</i> contains the root of the drive on which the free space changed.
106 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
108 SHCNE_FREESPACE = 0x00040000,
111 /// Storage media has been inserted into a drive.
112 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
113 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
114 /// <i>dwItem1</i> contains the root of the drive that contains the new media.
115 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
117 SHCNE_MEDIAINSERTED = 0x00000020,
120 /// Storage media has been removed from a drive.
121 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
122 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
123 /// <i>dwItem1</i> contains the root of the drive from which the media was removed.
124 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
126 SHCNE_MEDIAREMOVED = 0x00000040,
129 /// A folder has been created. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/>
130 /// or <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
131 /// <i>dwItem1</i> contains the folder that was created.
132 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
134 SHCNE_MKDIR = 0x00000008,
137 /// A folder on the local computer is being shared via the network.
138 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
139 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
140 /// <i>dwItem1</i> contains the folder that is being shared.
141 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
143 SHCNE_NETSHARE = 0x00000200,
146 /// A folder on the local computer is no longer being shared via the network.
147 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
148 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
149 /// <i>dwItem1</i> contains the folder that is no longer being shared.
150 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
152 SHCNE_NETUNSHARE = 0x00000400,
155 /// The name of a folder has changed.
156 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
157 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
158 /// <i>dwItem1</i> contains the previous pointer to an item identifier list (PIDL) or name of the folder.
159 /// <i>dwItem2</i> contains the new PIDL or name of the folder.
161 SHCNE_RENAMEFOLDER = 0x00020000,
164 /// The name of a nonfolder item has changed.
165 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
166 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
167 /// <i>dwItem1</i> contains the previous PIDL or name of the item.
168 /// <i>dwItem2</i> contains the new PIDL or name of the item.
170 SHCNE_RENAMEITEM = 0x00000001,
173 /// A folder has been removed.
174 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
175 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
176 /// <i>dwItem1</i> contains the folder that was removed.
177 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
179 SHCNE_RMDIR = 0x00000010,
182 /// The computer has disconnected from a server.
183 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
184 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
185 /// <i>dwItem1</i> contains the server from which the computer was disconnected.
186 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
188 SHCNE_SERVERDISCONNECT = 0x00004000,
191 /// The contents of an existing folder have changed,
192 /// but the folder still exists and has not been renamed.
193 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
194 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
195 /// <i>dwItem1</i> contains the folder that has changed.
196 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
197 /// If a folder has been created, deleted, or renamed, use SHCNE_MKDIR, SHCNE_RMDIR, or
198 /// SHCNE_RENAMEFOLDER, respectively, instead.
200 SHCNE_UPDATEDIR = 0x00001000,
202 SHCNE_UPDATEITEM = 0x00002000,
205 /// An image in the system image list has changed.
206 /// <see cref="HChangeNotifyFlags.SHCNF_DWORD"/> must be specified in <i>uFlags</i>.
208 SHCNE_UPDATEIMAGE = 0x00008000,
211 #endregion // enum HChangeNotifyEventID
213 #region public enum HChangeNotifyFlags
215 /// Flags that indicate the meaning of the <i>dwItem1</i> and <i>dwItem2</i> parameters.
216 /// The uFlags parameter must be one of the following values.
219 public enum HChangeNotifyFlags
222 /// The <i>dwItem1</i> and <i>dwItem2</i> parameters are DWORD values.
224 SHCNF_DWORD = 0x0003,
226 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of ITEMIDLIST structures that
227 /// represent the item(s) affected by the change.
228 /// Each ITEMIDLIST must be relative to the desktop folder.
230 SHCNF_IDLIST = 0x0000,
232 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of
233 /// maximum length MAX_PATH that contain the full path names
234 /// of the items affected by the change.
236 SHCNF_PATHA = 0x0001,
238 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of
239 /// maximum length MAX_PATH that contain the full path names
240 /// of the items affected by the change.
242 SHCNF_PATHW = 0x0005,
244 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that
245 /// represent the friendly names of the printer(s) affected by the change.
247 SHCNF_PRINTERA = 0x0002,
249 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that
250 /// represent the friendly names of the printer(s) affected by the change.
252 SHCNF_PRINTERW = 0x0006,
254 /// The function should not return until the notification
255 /// has been delivered to all affected components.
256 /// As this flag modifies other data-type flags, it cannot by used by itself.
258 SHCNF_FLUSH = 0x1000,
260 /// The function should begin delivering notifications to all affected components
261 /// but should return as soon as the notification process has begun.
262 /// As this flag modifies other data-type flags, it cannot by used by itself.
264 SHCNF_FLUSHNOWAIT = 0x2000
266 #endregion // enum HChangeNotifyFlags
272 internal static class NativeMethods
274 [DllImport("shell32.dll")]
275 public static extern void SHChangeNotify(HChangeNotifyEventID wEventId,
276 HChangeNotifyFlags uFlags,