Statistics
| Branch: | Revision:

root / trunk / Pithos.Core / NativeMethods.cs @ 7b0a5fec

History | View | Annotate | Download (13.4 kB)

1 d78cbf09 Panagiotis Kanavos
using System;
2 d78cbf09 Panagiotis Kanavos
using System.Collections.Generic;
3 5ce54458 Panagiotis Kanavos
using System.IO;
4 d78cbf09 Panagiotis Kanavos
using System.Linq;
5 d78cbf09 Panagiotis Kanavos
using System.Runtime.InteropServices;
6 d78cbf09 Panagiotis Kanavos
using System.Text;
7 d78cbf09 Panagiotis Kanavos
8 d78cbf09 Panagiotis Kanavos
namespace Pithos.Core
9 d78cbf09 Panagiotis Kanavos
{
10 d78cbf09 Panagiotis Kanavos
    #region Enums & Structs
11 d78cbf09 Panagiotis Kanavos
12 d78cbf09 Panagiotis Kanavos
    #region enum HChangeNotifyEventID
13 d78cbf09 Panagiotis Kanavos
    /// <summary>
14 d78cbf09 Panagiotis Kanavos
    /// Describes the event that has occurred. 
15 d78cbf09 Panagiotis Kanavos
    /// Typically, only one event is specified at a time. 
16 d78cbf09 Panagiotis Kanavos
    /// If more than one event is specified, the values contained 
17 d78cbf09 Panagiotis Kanavos
    /// in the <i>dwItem1</i> and <i>dwItem2</i> 
18 d78cbf09 Panagiotis Kanavos
    /// parameters must be the same, respectively, for all specified events. 
19 d78cbf09 Panagiotis Kanavos
    /// This parameter can be one or more of the following values. 
20 d78cbf09 Panagiotis Kanavos
    /// </summary>
21 d78cbf09 Panagiotis Kanavos
    /// <remarks>
22 d78cbf09 Panagiotis Kanavos
    /// <para><b>Windows NT/2000/XP:</b> <i>dwItem2</i> contains the index 
23 d78cbf09 Panagiotis Kanavos
    /// in the system image list that has changed. 
24 d78cbf09 Panagiotis Kanavos
    /// <i>dwItem1</i> is not used and should be <see langword="null"/>.</para>
25 d78cbf09 Panagiotis Kanavos
    /// <para><b>Windows 95/98:</b> <i>dwItem1</i> contains the index 
26 d78cbf09 Panagiotis Kanavos
    /// in the system image list that has changed. 
27 d78cbf09 Panagiotis Kanavos
    /// <i>dwItem2</i> is not used and should be <see langword="null"/>.</para>
28 d78cbf09 Panagiotis Kanavos
    /// </remarks>
29 d78cbf09 Panagiotis Kanavos
    [Flags]
30 5ce54458 Panagiotis Kanavos
    public enum HChangeNotifyEventID
31 d78cbf09 Panagiotis Kanavos
    {
32 d78cbf09 Panagiotis Kanavos
        /// <summary>
33 d78cbf09 Panagiotis Kanavos
        /// All events have occurred. 
34 d78cbf09 Panagiotis Kanavos
        /// </summary>
35 d78cbf09 Panagiotis Kanavos
        SHCNE_ALLEVENTS = 0x7FFFFFFF,
36 d78cbf09 Panagiotis Kanavos
37 d78cbf09 Panagiotis Kanavos
        /// <summary>
38 d78cbf09 Panagiotis Kanavos
        /// A file type association has changed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> 
39 d78cbf09 Panagiotis Kanavos
        /// must be specified in the <i>uFlags</i> parameter. 
40 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are not used and must be <see langword="null"/>. 
41 d78cbf09 Panagiotis Kanavos
        /// </summary>
42 d78cbf09 Panagiotis Kanavos
        SHCNE_ASSOCCHANGED = 0x08000000,
43 d78cbf09 Panagiotis Kanavos
44 d78cbf09 Panagiotis Kanavos
        /// <summary>
45 d78cbf09 Panagiotis Kanavos
        /// The attributes of an item or folder have changed. 
46 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
47 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
48 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the item or folder that has changed. 
49 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
50 d78cbf09 Panagiotis Kanavos
        /// </summary>
51 d78cbf09 Panagiotis Kanavos
        SHCNE_ATTRIBUTES = 0x00000800,
52 d78cbf09 Panagiotis Kanavos
53 d78cbf09 Panagiotis Kanavos
        /// <summary>
54 d78cbf09 Panagiotis Kanavos
        /// A nonfolder item has been created. 
55 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
56 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
57 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the item that was created. 
58 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>.
59 d78cbf09 Panagiotis Kanavos
        /// </summary>
60 d78cbf09 Panagiotis Kanavos
        SHCNE_CREATE = 0x00000002,
61 d78cbf09 Panagiotis Kanavos
62 d78cbf09 Panagiotis Kanavos
        /// <summary>
63 d78cbf09 Panagiotis Kanavos
        /// A nonfolder item has been deleted. 
64 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
65 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
66 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the item that was deleted. 
67 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
68 d78cbf09 Panagiotis Kanavos
        /// </summary>
69 d78cbf09 Panagiotis Kanavos
        SHCNE_DELETE = 0x00000004,
70 d78cbf09 Panagiotis Kanavos
71 d78cbf09 Panagiotis Kanavos
        /// <summary>
72 d78cbf09 Panagiotis Kanavos
        /// A drive has been added. 
73 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
74 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
75 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive that was added. 
76 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
77 d78cbf09 Panagiotis Kanavos
        /// </summary>
78 d78cbf09 Panagiotis Kanavos
        SHCNE_DRIVEADD = 0x00000100,
79 d78cbf09 Panagiotis Kanavos
80 d78cbf09 Panagiotis Kanavos
        /// <summary>
81 d78cbf09 Panagiotis Kanavos
        /// A drive has been added and the Shell should create a new window for the drive. 
82 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
83 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
84 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive that was added. 
85 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
86 d78cbf09 Panagiotis Kanavos
        /// </summary>
87 d78cbf09 Panagiotis Kanavos
        SHCNE_DRIVEADDGUI = 0x00010000,
88 d78cbf09 Panagiotis Kanavos
89 d78cbf09 Panagiotis Kanavos
        /// <summary>
90 d78cbf09 Panagiotis Kanavos
        /// A drive has been removed. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
91 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
92 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive that was removed.
93 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
94 d78cbf09 Panagiotis Kanavos
        /// </summary>
95 d78cbf09 Panagiotis Kanavos
        SHCNE_DRIVEREMOVED = 0x00000080,
96 d78cbf09 Panagiotis Kanavos
97 d78cbf09 Panagiotis Kanavos
        /// <summary>
98 d78cbf09 Panagiotis Kanavos
        /// Not currently used. 
99 d78cbf09 Panagiotis Kanavos
        /// </summary>
100 d78cbf09 Panagiotis Kanavos
        SHCNE_EXTENDED_EVENT = 0x04000000,
101 d78cbf09 Panagiotis Kanavos
102 d78cbf09 Panagiotis Kanavos
        /// <summary>
103 d78cbf09 Panagiotis Kanavos
        /// The amount of free space on a drive has changed. 
104 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
105 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
106 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive on which the free space changed.
107 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
108 d78cbf09 Panagiotis Kanavos
        /// </summary>
109 d78cbf09 Panagiotis Kanavos
        SHCNE_FREESPACE = 0x00040000,
110 d78cbf09 Panagiotis Kanavos
111 d78cbf09 Panagiotis Kanavos
        /// <summary>
112 d78cbf09 Panagiotis Kanavos
        /// Storage media has been inserted into a drive. 
113 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
114 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
115 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive that contains the new media. 
116 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
117 d78cbf09 Panagiotis Kanavos
        /// </summary>
118 d78cbf09 Panagiotis Kanavos
        SHCNE_MEDIAINSERTED = 0x00000020,
119 d78cbf09 Panagiotis Kanavos
120 d78cbf09 Panagiotis Kanavos
        /// <summary>
121 d78cbf09 Panagiotis Kanavos
        /// Storage media has been removed from a drive. 
122 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
123 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
124 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the root of the drive from which the media was removed. 
125 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
126 d78cbf09 Panagiotis Kanavos
        /// </summary>
127 d78cbf09 Panagiotis Kanavos
        SHCNE_MEDIAREMOVED = 0x00000040,
128 d78cbf09 Panagiotis Kanavos
129 d78cbf09 Panagiotis Kanavos
        /// <summary>
130 d78cbf09 Panagiotis Kanavos
        /// A folder has been created. <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> 
131 d78cbf09 Panagiotis Kanavos
        /// or <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
132 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the folder that was created. 
133 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
134 d78cbf09 Panagiotis Kanavos
        /// </summary>
135 d78cbf09 Panagiotis Kanavos
        SHCNE_MKDIR = 0x00000008,
136 d78cbf09 Panagiotis Kanavos
137 d78cbf09 Panagiotis Kanavos
        /// <summary>
138 d78cbf09 Panagiotis Kanavos
        /// A folder on the local computer is being shared via the network. 
139 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
140 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
141 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the folder that is being shared. 
142 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
143 d78cbf09 Panagiotis Kanavos
        /// </summary>
144 d78cbf09 Panagiotis Kanavos
        SHCNE_NETSHARE = 0x00000200,
145 d78cbf09 Panagiotis Kanavos
146 d78cbf09 Panagiotis Kanavos
        /// <summary>
147 d78cbf09 Panagiotis Kanavos
        /// A folder on the local computer is no longer being shared via the network. 
148 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
149 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
150 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the folder that is no longer being shared. 
151 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
152 d78cbf09 Panagiotis Kanavos
        /// </summary>
153 d78cbf09 Panagiotis Kanavos
        SHCNE_NETUNSHARE = 0x00000400,
154 d78cbf09 Panagiotis Kanavos
155 d78cbf09 Panagiotis Kanavos
        /// <summary>
156 d78cbf09 Panagiotis Kanavos
        /// The name of a folder has changed. 
157 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
158 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
159 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the previous pointer to an item identifier list (PIDL) or name of the folder. 
160 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> contains the new PIDL or name of the folder. 
161 d78cbf09 Panagiotis Kanavos
        /// </summary>
162 d78cbf09 Panagiotis Kanavos
        SHCNE_RENAMEFOLDER = 0x00020000,
163 d78cbf09 Panagiotis Kanavos
164 d78cbf09 Panagiotis Kanavos
        /// <summary>
165 d78cbf09 Panagiotis Kanavos
        /// The name of a nonfolder item has changed. 
166 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
167 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
168 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the previous PIDL or name of the item. 
169 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> contains the new PIDL or name of the item. 
170 d78cbf09 Panagiotis Kanavos
        /// </summary>
171 d78cbf09 Panagiotis Kanavos
        SHCNE_RENAMEITEM = 0x00000001,
172 d78cbf09 Panagiotis Kanavos
173 d78cbf09 Panagiotis Kanavos
        /// <summary>
174 d78cbf09 Panagiotis Kanavos
        /// A folder has been removed. 
175 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
176 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
177 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the folder that was removed. 
178 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
179 d78cbf09 Panagiotis Kanavos
        /// </summary>
180 d78cbf09 Panagiotis Kanavos
        SHCNE_RMDIR = 0x00000010,
181 d78cbf09 Panagiotis Kanavos
182 d78cbf09 Panagiotis Kanavos
        /// <summary>
183 d78cbf09 Panagiotis Kanavos
        /// The computer has disconnected from a server. 
184 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
185 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
186 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the server from which the computer was disconnected. 
187 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
188 d78cbf09 Panagiotis Kanavos
        /// </summary>
189 d78cbf09 Panagiotis Kanavos
        SHCNE_SERVERDISCONNECT = 0x00004000,
190 d78cbf09 Panagiotis Kanavos
191 d78cbf09 Panagiotis Kanavos
        /// <summary>
192 d78cbf09 Panagiotis Kanavos
        /// The contents of an existing folder have changed, 
193 d78cbf09 Panagiotis Kanavos
        /// but the folder still exists and has not been renamed. 
194 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_IDLIST"/> or 
195 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_PATH"/> must be specified in <i>uFlags</i>. 
196 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> contains the folder that has changed. 
197 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem2</i> is not used and should be <see langword="null"/>. 
198 d78cbf09 Panagiotis Kanavos
        /// If a folder has been created, deleted, or renamed, use SHCNE_MKDIR, SHCNE_RMDIR, or 
199 d78cbf09 Panagiotis Kanavos
        /// SHCNE_RENAMEFOLDER, respectively, instead. 
200 d78cbf09 Panagiotis Kanavos
        /// </summary>
201 d78cbf09 Panagiotis Kanavos
        SHCNE_UPDATEDIR = 0x00001000,
202 d78cbf09 Panagiotis Kanavos
203 d78cbf09 Panagiotis Kanavos
        SHCNE_UPDATEITEM = 0x00002000,
204 d78cbf09 Panagiotis Kanavos
205 d78cbf09 Panagiotis Kanavos
        /// <summary>
206 d78cbf09 Panagiotis Kanavos
        /// An image in the system image list has changed. 
207 d78cbf09 Panagiotis Kanavos
        /// <see cref="HChangeNotifyFlags.SHCNF_DWORD"/> must be specified in <i>uFlags</i>. 
208 d78cbf09 Panagiotis Kanavos
        /// </summary>
209 d78cbf09 Panagiotis Kanavos
        SHCNE_UPDATEIMAGE = 0x00008000,
210 d78cbf09 Panagiotis Kanavos
211 d78cbf09 Panagiotis Kanavos
    }
212 d78cbf09 Panagiotis Kanavos
    #endregion // enum HChangeNotifyEventID
213 d78cbf09 Panagiotis Kanavos
214 d78cbf09 Panagiotis Kanavos
    #region public enum HChangeNotifyFlags
215 d78cbf09 Panagiotis Kanavos
    /// <summary>
216 d78cbf09 Panagiotis Kanavos
    /// Flags that indicate the meaning of the <i>dwItem1</i> and <i>dwItem2</i> parameters. 
217 d78cbf09 Panagiotis Kanavos
    /// The uFlags parameter must be one of the following values.
218 d78cbf09 Panagiotis Kanavos
    /// </summary>
219 d78cbf09 Panagiotis Kanavos
    [Flags]
220 d78cbf09 Panagiotis Kanavos
    public enum HChangeNotifyFlags
221 d78cbf09 Panagiotis Kanavos
    {
222 d78cbf09 Panagiotis Kanavos
        /// <summary>
223 d78cbf09 Panagiotis Kanavos
        /// The <i>dwItem1</i> and <i>dwItem2</i> parameters are DWORD values. 
224 d78cbf09 Panagiotis Kanavos
        /// </summary>
225 d78cbf09 Panagiotis Kanavos
        SHCNF_DWORD = 0x0003,
226 d78cbf09 Panagiotis Kanavos
        /// <summary>
227 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of ITEMIDLIST structures that 
228 d78cbf09 Panagiotis Kanavos
        /// represent the item(s) affected by the change. 
229 d78cbf09 Panagiotis Kanavos
        /// Each ITEMIDLIST must be relative to the desktop folder. 
230 d78cbf09 Panagiotis Kanavos
        /// </summary>
231 d78cbf09 Panagiotis Kanavos
        SHCNF_IDLIST = 0x0000,
232 d78cbf09 Panagiotis Kanavos
        /// <summary>
233 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of 
234 d78cbf09 Panagiotis Kanavos
        /// maximum length MAX_PATH that contain the full path names 
235 d78cbf09 Panagiotis Kanavos
        /// of the items affected by the change. 
236 d78cbf09 Panagiotis Kanavos
        /// </summary>
237 d78cbf09 Panagiotis Kanavos
        SHCNF_PATHA = 0x0001,
238 d78cbf09 Panagiotis Kanavos
        /// <summary>
239 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings of 
240 d78cbf09 Panagiotis Kanavos
        /// maximum length MAX_PATH that contain the full path names 
241 d78cbf09 Panagiotis Kanavos
        /// of the items affected by the change. 
242 d78cbf09 Panagiotis Kanavos
        /// </summary>
243 d78cbf09 Panagiotis Kanavos
        SHCNF_PATHW = 0x0005,
244 d78cbf09 Panagiotis Kanavos
        /// <summary>
245 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that 
246 d78cbf09 Panagiotis Kanavos
        /// represent the friendly names of the printer(s) affected by the change. 
247 d78cbf09 Panagiotis Kanavos
        /// </summary>
248 d78cbf09 Panagiotis Kanavos
        SHCNF_PRINTERA = 0x0002,
249 d78cbf09 Panagiotis Kanavos
        /// <summary>
250 d78cbf09 Panagiotis Kanavos
        /// <i>dwItem1</i> and <i>dwItem2</i> are the addresses of null-terminated strings that 
251 d78cbf09 Panagiotis Kanavos
        /// represent the friendly names of the printer(s) affected by the change. 
252 d78cbf09 Panagiotis Kanavos
        /// </summary>
253 d78cbf09 Panagiotis Kanavos
        SHCNF_PRINTERW = 0x0006,
254 d78cbf09 Panagiotis Kanavos
        /// <summary>
255 d78cbf09 Panagiotis Kanavos
        /// The function should not return until the notification 
256 d78cbf09 Panagiotis Kanavos
        /// has been delivered to all affected components. 
257 d78cbf09 Panagiotis Kanavos
        /// As this flag modifies other data-type flags, it cannot by used by itself.
258 d78cbf09 Panagiotis Kanavos
        /// </summary>
259 d78cbf09 Panagiotis Kanavos
        SHCNF_FLUSH = 0x1000,
260 d78cbf09 Panagiotis Kanavos
        /// <summary>
261 d78cbf09 Panagiotis Kanavos
        /// The function should begin delivering notifications to all affected components 
262 d78cbf09 Panagiotis Kanavos
        /// but should return as soon as the notification process has begun. 
263 d78cbf09 Panagiotis Kanavos
        /// As this flag modifies other data-type flags, it cannot by used by itself.
264 d78cbf09 Panagiotis Kanavos
        /// </summary>
265 d78cbf09 Panagiotis Kanavos
        SHCNF_FLUSHNOWAIT = 0x2000
266 d78cbf09 Panagiotis Kanavos
    }
267 d78cbf09 Panagiotis Kanavos
    #endregion // enum HChangeNotifyFlags
268 d78cbf09 Panagiotis Kanavos
269 d78cbf09 Panagiotis Kanavos
270 d78cbf09 Panagiotis Kanavos
    #endregion
271 d78cbf09 Panagiotis Kanavos
272 5ce54458 Panagiotis Kanavos
    public static class NativeMethods
273 d78cbf09 Panagiotis Kanavos
    {
274 d78cbf09 Panagiotis Kanavos
        [DllImport("shell32.dll")]
275 d78cbf09 Panagiotis Kanavos
        public static extern void SHChangeNotify(HChangeNotifyEventID wEventId,
276 d78cbf09 Panagiotis Kanavos
                                           HChangeNotifyFlags uFlags,
277 d78cbf09 Panagiotis Kanavos
                                           IntPtr dwItem1,
278 d78cbf09 Panagiotis Kanavos
                                           IntPtr dwItem2);
279 d78cbf09 Panagiotis Kanavos
280 5ce54458 Panagiotis Kanavos
        public static void RaiseChangeNotification(string path)
281 5ce54458 Panagiotis Kanavos
        {
282 5ce54458 Panagiotis Kanavos
            if (String.IsNullOrWhiteSpace(path))
283 5ce54458 Panagiotis Kanavos
                throw new ArgumentNullException("path", "The path parameter must not be emtpy");
284 5ce54458 Panagiotis Kanavos
285 5ce54458 Panagiotis Kanavos
            if (!Directory.Exists(path) && !File.Exists(path))
286 5ce54458 Panagiotis Kanavos
                throw new FileNotFoundException("The specified file or path does not exist", path);
287 5ce54458 Panagiotis Kanavos
288 5ce54458 Panagiotis Kanavos
289 5ce54458 Panagiotis Kanavos
            IntPtr pathPointer = Marshal.StringToCoTaskMemAuto(path);
290 5ce54458 Panagiotis Kanavos
291 5ce54458 Panagiotis Kanavos
            try
292 5ce54458 Panagiotis Kanavos
            {
293 5ce54458 Panagiotis Kanavos
                NativeMethods.SHChangeNotify(HChangeNotifyEventID.SHCNE_UPDATEITEM,
294 5ce54458 Panagiotis Kanavos
                                             HChangeNotifyFlags.SHCNF_PATHW | HChangeNotifyFlags.SHCNF_FLUSHNOWAIT,
295 5ce54458 Panagiotis Kanavos
                                             pathPointer, IntPtr.Zero);
296 5ce54458 Panagiotis Kanavos
            }
297 5ce54458 Panagiotis Kanavos
            finally
298 5ce54458 Panagiotis Kanavos
            {
299 5ce54458 Panagiotis Kanavos
                Marshal.FreeHGlobal(pathPointer);
300 5ce54458 Panagiotis Kanavos
            }
301 5ce54458 Panagiotis Kanavos
302 5ce54458 Panagiotis Kanavos
        }
303 d78cbf09 Panagiotis Kanavos
    }
304 5ce54458 Panagiotis Kanavos
305 5ce54458 Panagiotis Kanavos
306 d78cbf09 Panagiotis Kanavos
}