2 using System.Runtime.InteropServices;
4 namespace Pithos.Client.WPF
6 #region Enums & Structs
8 #region enum HChangeNotifyEventID
10 /// Describes the event that has occurred.
11 /// Typically, only one event is specified at a time.
12 /// If more than one event is specified, the values contained
13 /// in the <i>dwItem1</i> and <i>dwItem2</i>
14 /// parameters must be the same, respectively, for all specified events.
15 /// This parameter can be one or more of the following values.
18 /// <para><b>Windows NT/2000/XP:</b> <i>dwItem2</i> contains the index
19 /// in the system image list that has changed.
20 /// <i>dwItem1</i> is not used and should be <see langword="null"/>.</para>
21 /// <para><b>Windows 95/98:</b> <i>dwItem1</i> contains the index
22 /// in the system image list that has changed.
23 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.</para>
26 enum HChangeNotifyEventID
29 /// All events have occurred.
31 SHCNE_ALLEVENTS = 0x7FFFFFFF,
34 /// A file type association has changed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/>
35 /// must be specified in the <i>uFlags</i> parameter.
36 /// <i>dwItem1</i> and <i>dwItem2</i> are not used and must be <see langword="null"/>.
38 SHCNE_ASSOCCHANGED = 0x08000000,
41 /// The attributes of an item or folder have changed.
42 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
43 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
44 /// <i>dwItem1</i> contains the item or folder that has changed.
45 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
47 SHCNE_ATTRIBUTES = 0x00000800,
50 /// A nonfolder item has been created.
51 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
52 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
53 /// <i>dwItem1</i> contains the item that was created.
54 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
56 SHCNE_CREATE = 0x00000002,
59 /// A nonfolder item has been deleted.
60 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
61 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
62 /// <i>dwItem1</i> contains the item that was deleted.
63 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
65 SHCNE_DELETE = 0x00000004,
68 /// A drive has been added.
69 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
70 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
71 /// <i>dwItem1</i> contains the root of the drive that was added.
72 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
74 SHCNE_DRIVEADD = 0x00000100,
77 /// A drive has been added and the Shell should create a new window for the drive.
78 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
79 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
80 /// <i>dwItem1</i> contains the root of the drive that was added.
81 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
83 SHCNE_DRIVEADDGUI = 0x00010000,
86 /// A drive has been removed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
87 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
88 /// <i>dwItem1</i> contains the root of the drive that was removed.
89 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
91 SHCNE_DRIVEREMOVED = 0x00000080,
94 /// Not currently used.
96 SHCNE_EXTENDED_EVENT = 0x04000000,
99 /// The amount of free space on a drive has changed.
100 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
101 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
102 /// <i>dwItem1</i> contains the root of the drive on which the free space changed.
103 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
105 SHCNE_FREESPACE = 0x00040000,
108 /// Storage media has been inserted into a drive.
109 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
110 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
111 /// <i>dwItem1</i> contains the root of the drive that contains the new media.
112 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
114 SHCNE_MEDIAINSERTED = 0x00000020,
117 /// Storage media has been removed from a drive.
118 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
119 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
120 /// <i>dwItem1</i> contains the root of the drive from which the media was removed.
121 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
123 SHCNE_MEDIAREMOVED = 0x00000040,
126 /// A folder has been created. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/>
127 /// or <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
128 /// <i>dwItem1</i> contains the folder that was created.
129 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
131 SHCNE_MKDIR = 0x00000008,
134 /// A folder on the local computer is being shared via the network.
135 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
136 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
137 /// <i>dwItem1</i> contains the folder that is being shared.
138 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
140 SHCNE_NETSHARE = 0x00000200,
143 /// A folder on the local computer is no longer being shared via the network.
144 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
145 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
146 /// <i>dwItem1</i> contains the folder that is no longer being shared.
147 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
149 SHCNE_NETUNSHARE = 0x00000400,
152 /// The name of a folder has changed.
153 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
154 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
155 /// <i>dwItem1</i> contains the previous pointer to an item identifier list (PIDL) or name of the folder.
156 /// <i>dwItem2</i> contains the new PIDL or name of the folder.
158 SHCNE_RENAMEFOLDER = 0x00020000,
161 /// The name of a nonfolder item has changed.
162 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
163 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
164 /// <i>dwItem1</i> contains the previous PIDL or name of the item.
165 /// <i>dwItem2</i> contains the new PIDL or name of the item.
167 SHCNE_RENAMEITEM = 0x00000001,
170 /// A folder has been removed.
171 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
172 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
173 /// <i>dwItem1</i> contains the folder that was removed.
174 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
176 SHCNE_RMDIR = 0x00000010,
179 /// The computer has disconnected from a server.
180 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
181 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
182 /// <i>dwItem1</i> contains the server from which the computer was disconnected.
183 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
185 SHCNE_SERVERDISCONNECT = 0x00004000,
188 /// The contents of an existing folder have changed,
189 /// but the folder still exists and has not been renamed.
190 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
191 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
192 /// <i>dwItem1</i> contains the folder that has changed.
193 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
194 /// If a folder has been created, deleted, or renamed, use SHCNE_MKDIR, SHCNE_RMDIR, or
195 /// SHCNE_RENAMEFOLDER, respectively, instead.
197 SHCNE_UPDATEDIR = 0x00001000,
199 SHCNE_UPDATEITEM = 0x00002000,
202 /// An image in the system image list has changed.
203 /// <see cref="HChangeNotifyFlags.SHCNF_DWORD"/> must be specified in <i>uFlags</i>.
205 SHCNE_UPDATEIMAGE = 0x00008000,
208 #endregion // enum HChangeNotifyEventID
210 #region public enum HChangeNotifyFlags
212 /// Flags that indicate the meaning of the <i>dwItem1</i> and <i>dwItem2</i> parameters.
213 /// The uFlags parameter must be one of the following values.
216 public enum HChangeNotifyFlags
219 /// The <i>dwItem1</i> and <i>dwItem2</i> parameters are DWORD values.
221 SHCNF_DWORD = 0x0003,
223 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of ITEMIDLIST structures that
224 /// represent the item(s) affected by the change.
225 /// Each ITEMIDLIST must be relative to the desktop folder.
227 SHCNF_IDLIST = 0x0000,
229 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of
230 /// maximum length MAX_PATH that contain the full path names
231 /// of the items affected by the change.
233 SHCNF_PATHA = 0x0001,
235 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of
236 /// maximum length MAX_PATH that contain the full path names
237 /// of the items affected by the change.
239 SHCNF_PATHW = 0x0005,
241 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that
242 /// represent the friendly names of the printer(s) affected by the change.
244 SHCNF_PRINTERA = 0x0002,
246 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that
247 /// represent the friendly names of the printer(s) affected by the change.
249 SHCNF_PRINTERW = 0x0006,
251 /// The function should not return until the notification
252 /// has been delivered to all affected components.
253 /// As this flag modifies other data-type flags, it cannot by used by itself.
255 SHCNF_FLUSH = 0x1000,
257 /// The function should begin delivering notifications to all affected components
258 /// but should return as soon as the notification process has begun.
259 /// As this flag modifies other data-type flags, it cannot by used by itself.
261 SHCNF_FLUSHNOWAIT = 0x2000
263 #endregion // enum HChangeNotifyFlags
269 internal static class NativeMethods
271 [DllImport("shell32.dll")]
272 public static extern void SHChangeNotify(HChangeNotifyEventID wEventId,
273 HChangeNotifyFlags uFlags,