#region /* ----------------------------------------------------------------------- * * * Copyright 2011-2012 GRNET S.A. All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * 1. Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * 2. Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * The views and conclusions contained in the software and * documentation are those of the authors and should not be * interpreted as representing official policies, either expressed * or implied, of GRNET S.A. * * ----------------------------------------------------------------------- */ #endregion using System; using System.Runtime.InteropServices; namespace Pithos.Client.WPF { #region Enums & Structs #region enum HChangeNotifyEventID /// /// Describes the event that has occurred. /// Typically, only one event is specified at a time. /// If more than one event is specified, the values contained /// in the dwItem1 and dwItem2 /// parameters must be the same, respectively, for all specified events. /// This parameter can be one or more of the following values. /// /// /// Windows NT/2000/XP: dwItem2 contains the index /// in the system image list that has changed. /// dwItem1 is not used and should be . /// Windows 95/98: dwItem1 contains the index /// in the system image list that has changed. /// dwItem2 is not used and should be . /// [Flags] enum HChangeNotifyEventID { /// /// All events have occurred. /// SHCNE_ALLEVENTS = 0x7FFFFFFF, /// /// A file type association has changed. /// must be specified in the uFlags parameter. /// dwItem1 and dwItem2 are not used and must be . /// SHCNE_ASSOCCHANGED = 0x08000000, /// /// The attributes of an item or folder have changed. /// or /// must be specified in uFlags. /// dwItem1 contains the item or folder that has changed. /// dwItem2 is not used and should be . /// SHCNE_ATTRIBUTES = 0x00000800, /// /// A nonfolder item has been created. /// or /// must be specified in uFlags. /// dwItem1 contains the item that was created. /// dwItem2 is not used and should be . /// SHCNE_CREATE = 0x00000002, /// /// A nonfolder item has been deleted. /// or /// must be specified in uFlags. /// dwItem1 contains the item that was deleted. /// dwItem2 is not used and should be . /// SHCNE_DELETE = 0x00000004, /// /// A drive has been added. /// or /// must be specified in uFlags. /// dwItem1 contains the root of the drive that was added. /// dwItem2 is not used and should be . /// SHCNE_DRIVEADD = 0x00000100, /// /// A drive has been added and the Shell should create a new window for the drive. /// or /// must be specified in uFlags. /// dwItem1 contains the root of the drive that was added. /// dwItem2 is not used and should be . /// SHCNE_DRIVEADDGUI = 0x00010000, /// /// A drive has been removed. or /// must be specified in uFlags. /// dwItem1 contains the root of the drive that was removed. /// dwItem2 is not used and should be . /// SHCNE_DRIVEREMOVED = 0x00000080, /// /// Not currently used. /// SHCNE_EXTENDED_EVENT = 0x04000000, /// /// The amount of free space on a drive has changed. /// or /// must be specified in uFlags. /// dwItem1 contains the root of the drive on which the free space changed. /// dwItem2 is not used and should be . /// SHCNE_FREESPACE = 0x00040000, /// /// Storage media has been inserted into a drive. /// or /// must be specified in uFlags. /// dwItem1 contains the root of the drive that contains the new media. /// dwItem2 is not used and should be . /// SHCNE_MEDIAINSERTED = 0x00000020, /// /// Storage media has been removed from a drive. /// or /// must be specified in uFlags. /// dwItem1 contains the root of the drive from which the media was removed. /// dwItem2 is not used and should be . /// SHCNE_MEDIAREMOVED = 0x00000040, /// /// A folder has been created. /// or must be specified in uFlags. /// dwItem1 contains the folder that was created. /// dwItem2 is not used and should be . /// SHCNE_MKDIR = 0x00000008, /// /// A folder on the local computer is being shared via the network. /// or /// must be specified in uFlags. /// dwItem1 contains the folder that is being shared. /// dwItem2 is not used and should be . /// SHCNE_NETSHARE = 0x00000200, /// /// A folder on the local computer is no longer being shared via the network. /// or /// must be specified in uFlags. /// dwItem1 contains the folder that is no longer being shared. /// dwItem2 is not used and should be . /// SHCNE_NETUNSHARE = 0x00000400, /// /// The name of a folder has changed. /// or /// must be specified in uFlags. /// dwItem1 contains the previous pointer to an item identifier list (PIDL) or name of the folder. /// dwItem2 contains the new PIDL or name of the folder. /// SHCNE_RENAMEFOLDER = 0x00020000, /// /// The name of a nonfolder item has changed. /// or /// must be specified in uFlags. /// dwItem1 contains the previous PIDL or name of the item. /// dwItem2 contains the new PIDL or name of the item. /// SHCNE_RENAMEITEM = 0x00000001, /// /// A folder has been removed. /// or /// must be specified in uFlags. /// dwItem1 contains the folder that was removed. /// dwItem2 is not used and should be . /// SHCNE_RMDIR = 0x00000010, /// /// The computer has disconnected from a server. /// or /// must be specified in uFlags. /// dwItem1 contains the server from which the computer was disconnected. /// dwItem2 is not used and should be . /// SHCNE_SERVERDISCONNECT = 0x00004000, /// /// The contents of an existing folder have changed, /// but the folder still exists and has not been renamed. /// or /// must be specified in uFlags. /// dwItem1 contains the folder that has changed. /// dwItem2 is not used and should be . /// If a folder has been created, deleted, or renamed, use SHCNE_MKDIR, SHCNE_RMDIR, or /// SHCNE_RENAMEFOLDER, respectively, instead. /// SHCNE_UPDATEDIR = 0x00001000, SHCNE_UPDATEITEM = 0x00002000, /// /// An image in the system image list has changed. /// must be specified in uFlags. /// SHCNE_UPDATEIMAGE = 0x00008000, } #endregion // enum HChangeNotifyEventID #region public enum HChangeNotifyFlags /// /// Flags that indicate the meaning of the dwItem1 and dwItem2 parameters. /// The uFlags parameter must be one of the following values. /// [Flags] public enum HChangeNotifyFlags { /// /// The dwItem1 and dwItem2 parameters are DWORD values. /// SHCNF_DWORD = 0x0003, /// /// dwItem1 and dwItem2 are the addresses of ITEMIDLIST structures that /// represent the item(s) affected by the change. /// Each ITEMIDLIST must be relative to the desktop folder. /// SHCNF_IDLIST = 0x0000, /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings of /// maximum length MAX_PATH that contain the full path names /// of the items affected by the change. /// SHCNF_PATHA = 0x0001, /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings of /// maximum length MAX_PATH that contain the full path names /// of the items affected by the change. /// SHCNF_PATHW = 0x0005, /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings that /// represent the friendly names of the printer(s) affected by the change. /// SHCNF_PRINTERA = 0x0002, /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings that /// represent the friendly names of the printer(s) affected by the change. /// SHCNF_PRINTERW = 0x0006, /// /// The function should not return until the notification /// has been delivered to all affected components. /// As this flag modifies other data-type flags, it cannot by used by itself. /// SHCNF_FLUSH = 0x1000, /// /// The function should begin delivering notifications to all affected components /// but should return as soon as the notification process has begun. /// As this flag modifies other data-type flags, it cannot by used by itself. /// SHCNF_FLUSHNOWAIT = 0x2000 } #endregion // enum HChangeNotifyFlags #endregion internal static class NativeMethods { [DllImport("shell32.dll")] public static extern void SHChangeNotify(HChangeNotifyEventID wEventId, HChangeNotifyFlags uFlags, IntPtr dwItem1, IntPtr dwItem2); } }