Merge branch 'master' of \\\pk2010\Pithos\
[pithos-ms-client] / trunk / Pithos.Client.WPF / NativeMethods.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 namespace Pithos.Client.WPF
5 {
6     #region Enums & Structs
7
8     #region enum HChangeNotifyEventID
9     /// <summary>
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. 
16     /// </summary>
17     /// <remarks>
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>
24     /// </remarks>
25     [Flags]
26     enum HChangeNotifyEventID
27     {
28         /// <summary>
29         /// All events have occurred. 
30         /// </summary>
31         SHCNE_ALLEVENTS = 0x7FFFFFFF,
32
33         /// <summary>
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"/>. 
37         /// </summary>
38         SHCNE_ASSOCCHANGED = 0x08000000,
39
40         /// <summary>
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"/>.
46         /// </summary>
47         SHCNE_ATTRIBUTES = 0x00000800,
48
49         /// <summary>
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"/>.
55         /// </summary>
56         SHCNE_CREATE = 0x00000002,
57
58         /// <summary>
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"/>. 
64         /// </summary>
65         SHCNE_DELETE = 0x00000004,
66
67         /// <summary>
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"/>. 
73         /// </summary>
74         SHCNE_DRIVEADD = 0x00000100,
75
76         /// <summary>
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"/>. 
82         /// </summary>
83         SHCNE_DRIVEADDGUI = 0x00010000,
84
85         /// <summary>
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"/>. 
90         /// </summary>
91         SHCNE_DRIVEREMOVED = 0x00000080,
92
93         /// <summary>
94         /// Not currently used. 
95         /// </summary>
96         SHCNE_EXTENDED_EVENT = 0x04000000,
97
98         /// <summary>
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"/>. 
104         /// </summary>
105         SHCNE_FREESPACE = 0x00040000,
106
107         /// <summary>
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"/>. 
113         /// </summary>
114         SHCNE_MEDIAINSERTED = 0x00000020,
115
116         /// <summary>
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"/>. 
122         /// </summary>
123         SHCNE_MEDIAREMOVED = 0x00000040,
124
125         /// <summary>
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"/>. 
130         /// </summary>
131         SHCNE_MKDIR = 0x00000008,
132
133         /// <summary>
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"/>. 
139         /// </summary>
140         SHCNE_NETSHARE = 0x00000200,
141
142         /// <summary>
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"/>. 
148         /// </summary>
149         SHCNE_NETUNSHARE = 0x00000400,
150
151         /// <summary>
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. 
157         /// </summary>
158         SHCNE_RENAMEFOLDER = 0x00020000,
159
160         /// <summary>
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. 
166         /// </summary>
167         SHCNE_RENAMEITEM = 0x00000001,
168
169         /// <summary>
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"/>. 
175         /// </summary>
176         SHCNE_RMDIR = 0x00000010,
177
178         /// <summary>
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"/>. 
184         /// </summary>
185         SHCNE_SERVERDISCONNECT = 0x00004000,
186
187         /// <summary>
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. 
196         /// </summary>
197         SHCNE_UPDATEDIR = 0x00001000,
198
199         SHCNE_UPDATEITEM = 0x00002000,
200
201         /// <summary>
202         /// An image in the system image list has changed. 
203         /// <see cref="HChangeNotifyFlags.SHCNF_DWORD"/> must be specified in <i>uFlags</i>. 
204         /// </summary>
205         SHCNE_UPDATEIMAGE = 0x00008000,
206
207     }
208     #endregion // enum HChangeNotifyEventID
209
210     #region public enum HChangeNotifyFlags
211     /// <summary>
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.
214     /// </summary>
215     [Flags]
216     public enum HChangeNotifyFlags
217     {
218         /// <summary>
219         /// The <i>dwItem1</i> and <i>dwItem2</i> parameters are DWORD values. 
220         /// </summary>
221         SHCNF_DWORD = 0x0003,
222         /// <summary>
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. 
226         /// </summary>
227         SHCNF_IDLIST = 0x0000,
228         /// <summary>
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. 
232         /// </summary>
233         SHCNF_PATHA = 0x0001,
234         /// <summary>
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. 
238         /// </summary>
239         SHCNF_PATHW = 0x0005,
240         /// <summary>
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. 
243         /// </summary>
244         SHCNF_PRINTERA = 0x0002,
245         /// <summary>
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. 
248         /// </summary>
249         SHCNF_PRINTERW = 0x0006,
250         /// <summary>
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.
254         /// </summary>
255         SHCNF_FLUSH = 0x1000,
256         /// <summary>
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.
260         /// </summary>
261         SHCNF_FLUSHNOWAIT = 0x2000
262     }
263     #endregion // enum HChangeNotifyFlags
264
265
266     #endregion
267
268
269     internal static class NativeMethods
270     {
271         [DllImport("shell32.dll")]
272         public static extern void SHChangeNotify(HChangeNotifyEventID wEventId,
273                                            HChangeNotifyFlags uFlags,
274                                            IntPtr dwItem1,
275                                            IntPtr dwItem2);
276
277     }
278 }