Statistics
| Branch: | Revision:

root / trunk / Pithos.Core / NativeMethods.cs @ 92740b03

History | View | Annotate | Download (15.1 kB)

1 255f5f86 Panagiotis Kanavos
#region
2 255f5f86 Panagiotis Kanavos
/* -----------------------------------------------------------------------
3 255f5f86 Panagiotis Kanavos
 * <copyright file="NativeMethods.cs" company="GRNet">
4 255f5f86 Panagiotis Kanavos
 * 
5 255f5f86 Panagiotis Kanavos
 * Copyright 2011-2012 GRNET S.A. All rights reserved.
6 255f5f86 Panagiotis Kanavos
 *
7 255f5f86 Panagiotis Kanavos
 * Redistribution and use in source and binary forms, with or
8 255f5f86 Panagiotis Kanavos
 * without modification, are permitted provided that the following
9 255f5f86 Panagiotis Kanavos
 * conditions are met:
10 255f5f86 Panagiotis Kanavos
 *
11 255f5f86 Panagiotis Kanavos
 *   1. Redistributions of source code must retain the above
12 255f5f86 Panagiotis Kanavos
 *      copyright notice, this list of conditions and the following
13 255f5f86 Panagiotis Kanavos
 *      disclaimer.
14 255f5f86 Panagiotis Kanavos
 *
15 255f5f86 Panagiotis Kanavos
 *   2. Redistributions in binary form must reproduce the above
16 255f5f86 Panagiotis Kanavos
 *      copyright notice, this list of conditions and the following
17 255f5f86 Panagiotis Kanavos
 *      disclaimer in the documentation and/or other materials
18 255f5f86 Panagiotis Kanavos
 *      provided with the distribution.
19 255f5f86 Panagiotis Kanavos
 *
20 255f5f86 Panagiotis Kanavos
 *
21 255f5f86 Panagiotis Kanavos
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
22 255f5f86 Panagiotis Kanavos
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 255f5f86 Panagiotis Kanavos
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 255f5f86 Panagiotis Kanavos
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
25 255f5f86 Panagiotis Kanavos
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 255f5f86 Panagiotis Kanavos
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 255f5f86 Panagiotis Kanavos
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 255f5f86 Panagiotis Kanavos
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 255f5f86 Panagiotis Kanavos
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 255f5f86 Panagiotis Kanavos
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 255f5f86 Panagiotis Kanavos
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 255f5f86 Panagiotis Kanavos
 * POSSIBILITY OF SUCH DAMAGE.
33 255f5f86 Panagiotis Kanavos
 *
34 255f5f86 Panagiotis Kanavos
 * The views and conclusions contained in the software and
35 255f5f86 Panagiotis Kanavos
 * documentation are those of the authors and should not be
36 255f5f86 Panagiotis Kanavos
 * interpreted as representing official policies, either expressed
37 255f5f86 Panagiotis Kanavos
 * or implied, of GRNET S.A.
38 255f5f86 Panagiotis Kanavos
 * </copyright>
39 255f5f86 Panagiotis Kanavos
 * -----------------------------------------------------------------------
40 255f5f86 Panagiotis Kanavos
 */
41 255f5f86 Panagiotis Kanavos
#endregion
42 255f5f86 Panagiotis Kanavos
using System;
43 d78cbf09 Panagiotis Kanavos
using System.Collections.Generic;
44 5ce54458 Panagiotis Kanavos
using System.IO;
45 d78cbf09 Panagiotis Kanavos
using System.Linq;
46 d78cbf09 Panagiotis Kanavos
using System.Runtime.InteropServices;
47 d78cbf09 Panagiotis Kanavos
using System.Text;
48 d78cbf09 Panagiotis Kanavos
49 d78cbf09 Panagiotis Kanavos
namespace Pithos.Core
50 d78cbf09 Panagiotis Kanavos
{
51 d78cbf09 Panagiotis Kanavos
    #region Enums & Structs
52 d78cbf09 Panagiotis Kanavos
53 d78cbf09 Panagiotis Kanavos
    #region enum HChangeNotifyEventID
54 d78cbf09 Panagiotis Kanavos
    /// <summary>
55 d78cbf09 Panagiotis Kanavos
    /// Describes the event that has occurred. 
56 d78cbf09 Panagiotis Kanavos
    /// Typically, only one event is specified at a time. 
57 d78cbf09 Panagiotis Kanavos
    /// If more than one event is specified, the values contained 
58 d78cbf09 Panagiotis Kanavos
    /// in the <i>dwItem1</i> and <i>dwItem2</i> 
59 d78cbf09 Panagiotis Kanavos
    /// parameters must be the same, respectively, for all specified events. 
60 d78cbf09 Panagiotis Kanavos
    /// This parameter can be one or more of the following values. 
61 d78cbf09 Panagiotis Kanavos
    /// </summary>
62 d78cbf09 Panagiotis Kanavos
    /// <remarks>
63 d78cbf09 Panagiotis Kanavos
    /// <para><b>Windows NT/2000/XP:</b> <i>dwItem2</i> contains the index 
64 d78cbf09 Panagiotis Kanavos
    /// in the system image list that has changed. 
65 d78cbf09 Panagiotis Kanavos
    /// <i>dwItem1</i> is not used and should be <see langword="null"/>.</para>
66 d78cbf09 Panagiotis Kanavos
    /// <para><b>Windows 95/98:</b> <i>dwItem1</i> contains the index 
67 d78cbf09 Panagiotis Kanavos
    /// in the system image list that has changed. 
68 d78cbf09 Panagiotis Kanavos
    /// <i>dwItem2</i> is not used and should be <see langword="null"/>.</para>
69 d78cbf09 Panagiotis Kanavos
    /// </remarks>
70 d78cbf09 Panagiotis Kanavos
    [Flags]
71 5ce54458 Panagiotis Kanavos
    public enum HChangeNotifyEventID
72 d78cbf09 Panagiotis Kanavos
    {
73 d78cbf09 Panagiotis Kanavos
        /// <summary>
74 d78cbf09 Panagiotis Kanavos
        /// All events have occurred. 
75 d78cbf09 Panagiotis Kanavos
        /// </summary>
76 d78cbf09 Panagiotis Kanavos
        SHCNE_ALLEVENTS = 0x7FFFFFFF,
77 d78cbf09 Panagiotis Kanavos
78 d78cbf09 Panagiotis Kanavos
        /// <summary>
79 d78cbf09 Panagiotis Kanavos
        /// A file type association has changed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> 
80 d78cbf09 Panagiotis Kanavos
        /// must be specified in the <i>uFlags</i> parameter. 
81 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are not used and must be <see langword="null"/>. 
82 d78cbf09 Panagiotis Kanavos
        /// </summary>
83 d78cbf09 Panagiotis Kanavos
        SHCNE_ASSOCCHANGED = 0x08000000,
84 d78cbf09 Panagiotis Kanavos
85 d78cbf09 Panagiotis Kanavos
        /// <summary>
86 d78cbf09 Panagiotis Kanavos
        /// The attributes of an item or folder have changed. 
87 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
88 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
89 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the item or folder that has changed. 
90 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
91 d78cbf09 Panagiotis Kanavos
        /// </summary>
92 d78cbf09 Panagiotis Kanavos
        SHCNE_ATTRIBUTES = 0x00000800,
93 d78cbf09 Panagiotis Kanavos
94 d78cbf09 Panagiotis Kanavos
        /// <summary>
95 d78cbf09 Panagiotis Kanavos
        /// A nonfolder item has been created. 
96 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
97 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
98 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the item that was created. 
99 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
100 d78cbf09 Panagiotis Kanavos
        /// </summary>
101 d78cbf09 Panagiotis Kanavos
        SHCNE_CREATE = 0x00000002,
102 d78cbf09 Panagiotis Kanavos
103 d78cbf09 Panagiotis Kanavos
        /// <summary>
104 d78cbf09 Panagiotis Kanavos
        /// A nonfolder item has been deleted. 
105 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
106 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
107 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the item that was deleted. 
108 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
109 d78cbf09 Panagiotis Kanavos
        /// </summary>
110 d78cbf09 Panagiotis Kanavos
        SHCNE_DELETE = 0x00000004,
111 d78cbf09 Panagiotis Kanavos
112 d78cbf09 Panagiotis Kanavos
        /// <summary>
113 d78cbf09 Panagiotis Kanavos
        /// A drive has been added. 
114 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
115 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
116 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive that was added. 
117 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
118 d78cbf09 Panagiotis Kanavos
        /// </summary>
119 d78cbf09 Panagiotis Kanavos
        SHCNE_DRIVEADD = 0x00000100,
120 d78cbf09 Panagiotis Kanavos
121 d78cbf09 Panagiotis Kanavos
        /// <summary>
122 d78cbf09 Panagiotis Kanavos
        /// A drive has been added and the Shell should create a new window for the drive. 
123 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
124 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
125 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive that was added. 
126 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
127 d78cbf09 Panagiotis Kanavos
        /// </summary>
128 d78cbf09 Panagiotis Kanavos
        SHCNE_DRIVEADDGUI = 0x00010000,
129 d78cbf09 Panagiotis Kanavos
130 d78cbf09 Panagiotis Kanavos
        /// <summary>
131 d78cbf09 Panagiotis Kanavos
        /// A drive has been removed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
132 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
133 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive that was removed.
134 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
135 d78cbf09 Panagiotis Kanavos
        /// </summary>
136 d78cbf09 Panagiotis Kanavos
        SHCNE_DRIVEREMOVED = 0x00000080,
137 d78cbf09 Panagiotis Kanavos
138 d78cbf09 Panagiotis Kanavos
        /// <summary>
139 d78cbf09 Panagiotis Kanavos
        /// Not currently used. 
140 d78cbf09 Panagiotis Kanavos
        /// </summary>
141 d78cbf09 Panagiotis Kanavos
        SHCNE_EXTENDED_EVENT = 0x04000000,
142 d78cbf09 Panagiotis Kanavos
143 d78cbf09 Panagiotis Kanavos
        /// <summary>
144 d78cbf09 Panagiotis Kanavos
        /// The amount of free space on a drive has changed. 
145 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
146 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
147 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive on which the free space changed.
148 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
149 d78cbf09 Panagiotis Kanavos
        /// </summary>
150 d78cbf09 Panagiotis Kanavos
        SHCNE_FREESPACE = 0x00040000,
151 d78cbf09 Panagiotis Kanavos
152 d78cbf09 Panagiotis Kanavos
        /// <summary>
153 d78cbf09 Panagiotis Kanavos
        /// Storage media has been inserted into a drive. 
154 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
155 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
156 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive that contains the new media. 
157 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
158 d78cbf09 Panagiotis Kanavos
        /// </summary>
159 d78cbf09 Panagiotis Kanavos
        SHCNE_MEDIAINSERTED = 0x00000020,
160 d78cbf09 Panagiotis Kanavos
161 d78cbf09 Panagiotis Kanavos
        /// <summary>
162 d78cbf09 Panagiotis Kanavos
        /// Storage media has been removed from a drive. 
163 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
164 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
165 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive from which the media was removed. 
166 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
167 d78cbf09 Panagiotis Kanavos
        /// </summary>
168 d78cbf09 Panagiotis Kanavos
        SHCNE_MEDIAREMOVED = 0x00000040,
169 d78cbf09 Panagiotis Kanavos
170 d78cbf09 Panagiotis Kanavos
        /// <summary>
171 d78cbf09 Panagiotis Kanavos
        /// A folder has been created. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> 
172 d78cbf09 Panagiotis Kanavos
        /// or <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
173 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the folder that was created. 
174 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
175 d78cbf09 Panagiotis Kanavos
        /// </summary>
176 d78cbf09 Panagiotis Kanavos
        SHCNE_MKDIR = 0x00000008,
177 d78cbf09 Panagiotis Kanavos
178 d78cbf09 Panagiotis Kanavos
        /// <summary>
179 d78cbf09 Panagiotis Kanavos
        /// A folder on the local computer is being shared via the network. 
180 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
181 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
182 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the folder that is being shared. 
183 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
184 d78cbf09 Panagiotis Kanavos
        /// </summary>
185 d78cbf09 Panagiotis Kanavos
        SHCNE_NETSHARE = 0x00000200,
186 d78cbf09 Panagiotis Kanavos
187 d78cbf09 Panagiotis Kanavos
        /// <summary>
188 d78cbf09 Panagiotis Kanavos
        /// A folder on the local computer is no longer being shared via the network. 
189 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
190 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
191 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the folder that is no longer being shared. 
192 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
193 d78cbf09 Panagiotis Kanavos
        /// </summary>
194 d78cbf09 Panagiotis Kanavos
        SHCNE_NETUNSHARE = 0x00000400,
195 d78cbf09 Panagiotis Kanavos
196 d78cbf09 Panagiotis Kanavos
        /// <summary>
197 d78cbf09 Panagiotis Kanavos
        /// The name of a folder has changed. 
198 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
199 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
200 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the previous pointer to an item identifier list (PIDL) or name of the folder. 
201 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> contains the new PIDL or name of the folder. 
202 d78cbf09 Panagiotis Kanavos
        /// </summary>
203 d78cbf09 Panagiotis Kanavos
        SHCNE_RENAMEFOLDER = 0x00020000,
204 d78cbf09 Panagiotis Kanavos
205 d78cbf09 Panagiotis Kanavos
        /// <summary>
206 d78cbf09 Panagiotis Kanavos
        /// The name of a nonfolder item has changed. 
207 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
208 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
209 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the previous PIDL or name of the item. 
210 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> contains the new PIDL or name of the item. 
211 d78cbf09 Panagiotis Kanavos
        /// </summary>
212 d78cbf09 Panagiotis Kanavos
        SHCNE_RENAMEITEM = 0x00000001,
213 d78cbf09 Panagiotis Kanavos
214 d78cbf09 Panagiotis Kanavos
        /// <summary>
215 d78cbf09 Panagiotis Kanavos
        /// A folder has been removed. 
216 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
217 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
218 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the folder that was removed. 
219 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
220 d78cbf09 Panagiotis Kanavos
        /// </summary>
221 d78cbf09 Panagiotis Kanavos
        SHCNE_RMDIR = 0x00000010,
222 d78cbf09 Panagiotis Kanavos
223 d78cbf09 Panagiotis Kanavos
        /// <summary>
224 d78cbf09 Panagiotis Kanavos
        /// The computer has disconnected from a server. 
225 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
226 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
227 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the server from which the computer was disconnected. 
228 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
229 d78cbf09 Panagiotis Kanavos
        /// </summary>
230 d78cbf09 Panagiotis Kanavos
        SHCNE_SERVERDISCONNECT = 0x00004000,
231 d78cbf09 Panagiotis Kanavos
232 d78cbf09 Panagiotis Kanavos
        /// <summary>
233 d78cbf09 Panagiotis Kanavos
        /// The contents of an existing folder have changed, 
234 d78cbf09 Panagiotis Kanavos
        /// but the folder still exists and has not been renamed. 
235 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
236 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
237 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the folder that has changed. 
238 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
239 d78cbf09 Panagiotis Kanavos
        /// If a folder has been created, deleted, or renamed, use SHCNE_MKDIR, SHCNE_RMDIR, or 
240 d78cbf09 Panagiotis Kanavos
        /// SHCNE_RENAMEFOLDER, respectively, instead. 
241 d78cbf09 Panagiotis Kanavos
        /// </summary>
242 d78cbf09 Panagiotis Kanavos
        SHCNE_UPDATEDIR = 0x00001000,
243 d78cbf09 Panagiotis Kanavos
244 d78cbf09 Panagiotis Kanavos
        SHCNE_UPDATEITEM = 0x00002000,
245 d78cbf09 Panagiotis Kanavos
246 d78cbf09 Panagiotis Kanavos
        /// <summary>
247 d78cbf09 Panagiotis Kanavos
        /// An image in the system image list has changed. 
248 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_DWORD"/> must be specified in <i>uFlags</i>. 
249 d78cbf09 Panagiotis Kanavos
        /// </summary>
250 d78cbf09 Panagiotis Kanavos
        SHCNE_UPDATEIMAGE = 0x00008000,
251 d78cbf09 Panagiotis Kanavos
252 d78cbf09 Panagiotis Kanavos
    }
253 d78cbf09 Panagiotis Kanavos
    #endregion // enum HChangeNotifyEventID
254 d78cbf09 Panagiotis Kanavos
255 d78cbf09 Panagiotis Kanavos
    #region public enum HChangeNotifyFlags
256 d78cbf09 Panagiotis Kanavos
    /// <summary>
257 d78cbf09 Panagiotis Kanavos
    /// Flags that indicate the meaning of the <i>dwItem1</i> and <i>dwItem2</i> parameters. 
258 d78cbf09 Panagiotis Kanavos
    /// The uFlags parameter must be one of the following values.
259 d78cbf09 Panagiotis Kanavos
    /// </summary>
260 d78cbf09 Panagiotis Kanavos
    [Flags]
261 d78cbf09 Panagiotis Kanavos
    public enum HChangeNotifyFlags
262 d78cbf09 Panagiotis Kanavos
    {
263 d78cbf09 Panagiotis Kanavos
        /// <summary>
264 d78cbf09 Panagiotis Kanavos
        /// The <i>dwItem1</i> and <i>dwItem2</i> parameters are DWORD values. 
265 d78cbf09 Panagiotis Kanavos
        /// </summary>
266 d78cbf09 Panagiotis Kanavos
        SHCNF_DWORD = 0x0003,
267 d78cbf09 Panagiotis Kanavos
        /// <summary>
268 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of ITEMIDLIST structures that 
269 d78cbf09 Panagiotis Kanavos
        /// represent the item(s) affected by the change. 
270 d78cbf09 Panagiotis Kanavos
        /// Each ITEMIDLIST must be relative to the desktop folder. 
271 d78cbf09 Panagiotis Kanavos
        /// </summary>
272 d78cbf09 Panagiotis Kanavos
        SHCNF_IDLIST = 0x0000,
273 d78cbf09 Panagiotis Kanavos
        /// <summary>
274 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of 
275 d78cbf09 Panagiotis Kanavos
        /// maximum length MAX_PATH that contain the full path names 
276 d78cbf09 Panagiotis Kanavos
        /// of the items affected by the change. 
277 d78cbf09 Panagiotis Kanavos
        /// </summary>
278 d78cbf09 Panagiotis Kanavos
        SHCNF_PATHA = 0x0001,
279 d78cbf09 Panagiotis Kanavos
        /// <summary>
280 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of 
281 d78cbf09 Panagiotis Kanavos
        /// maximum length MAX_PATH that contain the full path names 
282 d78cbf09 Panagiotis Kanavos
        /// of the items affected by the change. 
283 d78cbf09 Panagiotis Kanavos
        /// </summary>
284 d78cbf09 Panagiotis Kanavos
        SHCNF_PATHW = 0x0005,
285 d78cbf09 Panagiotis Kanavos
        /// <summary>
286 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that 
287 d78cbf09 Panagiotis Kanavos
        /// represent the friendly names of the printer(s) affected by the change. 
288 d78cbf09 Panagiotis Kanavos
        /// </summary>
289 d78cbf09 Panagiotis Kanavos
        SHCNF_PRINTERA = 0x0002,
290 d78cbf09 Panagiotis Kanavos
        /// <summary>
291 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that 
292 d78cbf09 Panagiotis Kanavos
        /// represent the friendly names of the printer(s) affected by the change. 
293 d78cbf09 Panagiotis Kanavos
        /// </summary>
294 d78cbf09 Panagiotis Kanavos
        SHCNF_PRINTERW = 0x0006,
295 d78cbf09 Panagiotis Kanavos
        /// <summary>
296 d78cbf09 Panagiotis Kanavos
        /// The function should not return until the notification 
297 d78cbf09 Panagiotis Kanavos
        /// has been delivered to all affected components. 
298 d78cbf09 Panagiotis Kanavos
        /// As this flag modifies other data-type flags, it cannot by used by itself.
299 d78cbf09 Panagiotis Kanavos
        /// </summary>
300 d78cbf09 Panagiotis Kanavos
        SHCNF_FLUSH = 0x1000,
301 d78cbf09 Panagiotis Kanavos
        /// <summary>
302 d78cbf09 Panagiotis Kanavos
        /// The function should begin delivering notifications to all affected components 
303 d78cbf09 Panagiotis Kanavos
        /// but should return as soon as the notification process has begun. 
304 d78cbf09 Panagiotis Kanavos
        /// As this flag modifies other data-type flags, it cannot by used by itself.
305 d78cbf09 Panagiotis Kanavos
        /// </summary>
306 d78cbf09 Panagiotis Kanavos
        SHCNF_FLUSHNOWAIT = 0x2000
307 d78cbf09 Panagiotis Kanavos
    }
308 d78cbf09 Panagiotis Kanavos
    #endregion // enum HChangeNotifyFlags
309 d78cbf09 Panagiotis Kanavos
310 d78cbf09 Panagiotis Kanavos
311 d78cbf09 Panagiotis Kanavos
    #endregion
312 d78cbf09 Panagiotis Kanavos
313 5ce54458 Panagiotis Kanavos
    public static class NativeMethods
314 d78cbf09 Panagiotis Kanavos
    {
315 d78cbf09 Panagiotis Kanavos
        [DllImport("shell32.dll")]
316 d78cbf09 Panagiotis Kanavos
        public static extern void SHChangeNotify(HChangeNotifyEventID wEventId,
317 d78cbf09 Panagiotis Kanavos
                                           HChangeNotifyFlags uFlags,
318 d78cbf09 Panagiotis Kanavos
                                           IntPtr dwItem1,
319 d78cbf09 Panagiotis Kanavos
                                           IntPtr dwItem2);
320 d78cbf09 Panagiotis Kanavos
321 5ce54458 Panagiotis Kanavos
        public static void RaiseChangeNotification(string path)
322 5ce54458 Panagiotis Kanavos
        {
323 5ce54458 Panagiotis Kanavos
            if (String.IsNullOrWhiteSpace(path))
324 5ce54458 Panagiotis Kanavos
                throw new ArgumentNullException("path", "The path parameter must not be emtpy");
325 5ce54458 Panagiotis Kanavos
326 5ce54458 Panagiotis Kanavos
            if (!Directory.Exists(path) && !File.Exists(path))
327 a0dcfcc9 Panagiotis Kanavos
                return;
328 5ce54458 Panagiotis Kanavos
329 5ce54458 Panagiotis Kanavos
330 5ce54458 Panagiotis Kanavos
            IntPtr pathPointer = Marshal.StringToCoTaskMemAuto(path);
331 5ce54458 Panagiotis Kanavos
332 5ce54458 Panagiotis Kanavos
            try
333 5ce54458 Panagiotis Kanavos
            {
334 5ce54458 Panagiotis Kanavos
                NativeMethods.SHChangeNotify(HChangeNotifyEventID.SHCNE_UPDATEITEM,
335 5ce54458 Panagiotis Kanavos
                                             HChangeNotifyFlags.SHCNF_PATHW | HChangeNotifyFlags.SHCNF_FLUSHNOWAIT,
336 5ce54458 Panagiotis Kanavos
                                             pathPointer, IntPtr.Zero);
337 5ce54458 Panagiotis Kanavos
            }
338 5ce54458 Panagiotis Kanavos
            finally
339 5ce54458 Panagiotis Kanavos
            {
340 5ce54458 Panagiotis Kanavos
                Marshal.FreeHGlobal(pathPointer);
341 5ce54458 Panagiotis Kanavos
            }
342 5ce54458 Panagiotis Kanavos
343 5ce54458 Panagiotis Kanavos
        }
344 d78cbf09 Panagiotis Kanavos
    }
345 5ce54458 Panagiotis Kanavos
346 5ce54458 Panagiotis Kanavos
347 d78cbf09 Panagiotis Kanavos
}