2 /* -----------------------------------------------------------------------
3 * <copyright file="NativeMethods.cs" company="GRNet">
5 * Copyright 2011-2012 GRNET S.A. All rights reserved.
7 * Redistribution and use in source and binary forms, with or
8 * without modification, are permitted provided that the following
11 * 1. Redistributions of source code must retain the above
12 * copyright notice, this list of conditions and the following
15 * 2. Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials
18 * provided with the distribution.
21 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
34 * The views and conclusions contained in the software and
35 * documentation are those of the authors and should not be
36 * interpreted as representing official policies, either expressed
37 * or implied, of GRNET S.A.
39 * -----------------------------------------------------------------------
43 using System.Runtime.InteropServices;
45 namespace Pithos.Client.WPF
47 #region Enums & Structs
49 #region enum HChangeNotifyEventID
51 /// Describes the event that has occurred.
52 /// Typically, only one event is specified at a time.
53 /// If more than one event is specified, the values contained
54 /// in the <i>dwItem1</i> and <i>dwItem2</i>
55 /// parameters must be the same, respectively, for all specified events.
56 /// This parameter can be one or more of the following values.
59 /// <para><b>Windows NT/2000/XP:</b> <i>dwItem2</i> contains the index
60 /// in the system image list that has changed.
61 /// <i>dwItem1</i> is not used and should be <see langword="null"/>.</para>
62 /// <para><b>Windows 95/98:</b> <i>dwItem1</i> contains the index
63 /// in the system image list that has changed.
64 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.</para>
67 enum HChangeNotifyEventID
70 /// All events have occurred.
72 SHCNE_ALLEVENTS = 0x7FFFFFFF,
75 /// A file type association has changed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/>
76 /// must be specified in the <i>uFlags</i> parameter.
77 /// <i>dwItem1</i> and <i>dwItem2</i> are not used and must be <see langword="null"/>.
79 SHCNE_ASSOCCHANGED = 0x08000000,
82 /// The attributes of an item or folder have changed.
83 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
84 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
85 /// <i>dwItem1</i> contains the item or folder that has changed.
86 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
88 SHCNE_ATTRIBUTES = 0x00000800,
91 /// A nonfolder item has been created.
92 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
93 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
94 /// <i>dwItem1</i> contains the item that was created.
95 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
97 SHCNE_CREATE = 0x00000002,
100 /// A nonfolder item has been deleted.
101 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
102 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
103 /// <i>dwItem1</i> contains the item that was deleted.
104 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
106 SHCNE_DELETE = 0x00000004,
109 /// A drive has been added.
110 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
111 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
112 /// <i>dwItem1</i> contains the root of the drive that was added.
113 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
115 SHCNE_DRIVEADD = 0x00000100,
118 /// A drive has been added and the Shell should create a new window for the drive.
119 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
120 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
121 /// <i>dwItem1</i> contains the root of the drive that was added.
122 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
124 SHCNE_DRIVEADDGUI = 0x00010000,
127 /// A drive has been removed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
128 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
129 /// <i>dwItem1</i> contains the root of the drive that was removed.
130 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
132 SHCNE_DRIVEREMOVED = 0x00000080,
135 /// Not currently used.
137 SHCNE_EXTENDED_EVENT = 0x04000000,
140 /// The amount of free space on a drive has changed.
141 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
142 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
143 /// <i>dwItem1</i> contains the root of the drive on which the free space changed.
144 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
146 SHCNE_FREESPACE = 0x00040000,
149 /// Storage media has been inserted into a drive.
150 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
151 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
152 /// <i>dwItem1</i> contains the root of the drive that contains the new media.
153 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
155 SHCNE_MEDIAINSERTED = 0x00000020,
158 /// Storage media has been removed from a drive.
159 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
160 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
161 /// <i>dwItem1</i> contains the root of the drive from which the media was removed.
162 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
164 SHCNE_MEDIAREMOVED = 0x00000040,
167 /// A folder has been created. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/>
168 /// or <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
169 /// <i>dwItem1</i> contains the folder that was created.
170 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
172 SHCNE_MKDIR = 0x00000008,
175 /// A folder on the local computer is being shared via the network.
176 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
177 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
178 /// <i>dwItem1</i> contains the folder that is being shared.
179 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
181 SHCNE_NETSHARE = 0x00000200,
184 /// A folder on the local computer is no longer being shared via the network.
185 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
186 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
187 /// <i>dwItem1</i> contains the folder that is no longer being shared.
188 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
190 SHCNE_NETUNSHARE = 0x00000400,
193 /// The name of a folder has changed.
194 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
195 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
196 /// <i>dwItem1</i> contains the previous pointer to an item identifier list (PIDL) or name of the folder.
197 /// <i>dwItem2</i> contains the new PIDL or name of the folder.
199 SHCNE_RENAMEFOLDER = 0x00020000,
202 /// The name of a nonfolder item has changed.
203 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
204 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
205 /// <i>dwItem1</i> contains the previous PIDL or name of the item.
206 /// <i>dwItem2</i> contains the new PIDL or name of the item.
208 SHCNE_RENAMEITEM = 0x00000001,
211 /// A folder has been removed.
212 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
213 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
214 /// <i>dwItem1</i> contains the folder that was removed.
215 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
217 SHCNE_RMDIR = 0x00000010,
220 /// The computer has disconnected from a server.
221 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
222 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
223 /// <i>dwItem1</i> contains the server from which the computer was disconnected.
224 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
226 SHCNE_SERVERDISCONNECT = 0x00004000,
229 /// The contents of an existing folder have changed,
230 /// but the folder still exists and has not been renamed.
231 /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or
232 /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>.
233 /// <i>dwItem1</i> contains the folder that has changed.
234 /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
235 /// If a folder has been created, deleted, or renamed, use SHCNE_MKDIR, SHCNE_RMDIR, or
236 /// SHCNE_RENAMEFOLDER, respectively, instead.
238 SHCNE_UPDATEDIR = 0x00001000,
240 SHCNE_UPDATEITEM = 0x00002000,
243 /// An image in the system image list has changed.
244 /// <see cref="HChangeNotifyFlags.SHCNF_DWORD"/> must be specified in <i>uFlags</i>.
246 SHCNE_UPDATEIMAGE = 0x00008000,
249 #endregion // enum HChangeNotifyEventID
251 #region public enum HChangeNotifyFlags
253 /// Flags that indicate the meaning of the <i>dwItem1</i> and <i>dwItem2</i> parameters.
254 /// The uFlags parameter must be one of the following values.
257 public enum HChangeNotifyFlags
260 /// The <i>dwItem1</i> and <i>dwItem2</i> parameters are DWORD values.
262 SHCNF_DWORD = 0x0003,
264 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of ITEMIDLIST structures that
265 /// represent the item(s) affected by the change.
266 /// Each ITEMIDLIST must be relative to the desktop folder.
268 SHCNF_IDLIST = 0x0000,
270 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of
271 /// maximum length MAX_PATH that contain the full path names
272 /// of the items affected by the change.
274 SHCNF_PATHA = 0x0001,
276 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of
277 /// maximum length MAX_PATH that contain the full path names
278 /// of the items affected by the change.
280 SHCNF_PATHW = 0x0005,
282 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that
283 /// represent the friendly names of the printer(s) affected by the change.
285 SHCNF_PRINTERA = 0x0002,
287 /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that
288 /// represent the friendly names of the printer(s) affected by the change.
290 SHCNF_PRINTERW = 0x0006,
292 /// The function should not return until the notification
293 /// has been delivered to all affected components.
294 /// As this flag modifies other data-type flags, it cannot by used by itself.
296 SHCNF_FLUSH = 0x1000,
298 /// The function should begin delivering notifications to all affected components
299 /// but should return as soon as the notification process has begun.
300 /// As this flag modifies other data-type flags, it cannot by used by itself.
302 SHCNF_FLUSHNOWAIT = 0x2000
304 #endregion // enum HChangeNotifyFlags
310 internal static class NativeMethods
312 [DllImport("shell32.dll")]
313 public static extern void SHChangeNotify(HChangeNotifyEventID wEventId,
314 HChangeNotifyFlags uFlags,