欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#实现刷新桌面的方法

程序员文章站 2023-11-18 21:02:34
本文实例讲述了c#实现刷新桌面的方法。分享给大家供大家参考。具体如下: using system; using system.collections.gener...

本文实例讲述了c#实现刷新桌面的方法。分享给大家供大家参考。具体如下:

using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.runtime.interopservices;
namespace fileencryptproject.algorithm
{
  public class desktoprefurbish
  {
    /// <summary>
    /// 桌面刷新
    /// </summary>
    [dllimport("shell32.dll")]
    public static extern void shchangenotify(hchangenotifyeventid weventid, hchangenotifyflags uflags, intptr dwitem1, intptr dwitem2);
    public static void deskref()
    {
      shchangenotify(hchangenotifyeventid.shcne_assocchanged, hchangenotifyflags.shcnf_idlist, intptr.zero, intptr.zero);
    }
  }
  #region public enum hchangenotifyflags
  [flags]
  public enum hchangenotifyflags
  {
    shcnf_dword = 0x0003,
    shcnf_idlist = 0x0000,
    shcnf_patha = 0x0001,
    shcnf_pathw = 0x0005,
    shcnf_printera = 0x0002,
    shcnf_printerw = 0x0006,
    shcnf_flush = 0x1000,
    shcnf_flushnowait = 0x2000
  }
  #endregion//enum hchangenotifyflags
  #region enum hchangenotifyeventid
  [flags]
  public enum hchangenotifyeventid
  {
    shcne_allevents = 0x7fffffff,
    shcne_assocchanged = 0x08000000,
    shcne_attributes = 0x00000800,
    shcne_create = 0x00000002,
    shcne_delete = 0x00000004,
    shcne_driveadd = 0x00000100,
    shcne_driveaddgui = 0x00010000,
    shcne_driveremoved = 0x00000080,
    shcne_extended_event = 0x04000000,
    shcne_freespace = 0x00040000,
    shcne_mediainserted = 0x00000020,
    shcne_mediaremoved = 0x00000040,
    shcne_mkdir = 0x00000008,
    shcne_netshare = 0x00000200,
    shcne_netunshare = 0x00000400,
    shcne_renamefolder = 0x00020000,
    shcne_renameitem = 0x00000001,
    shcne_rmdir = 0x00000010,
    shcne_serverdisconnect = 0x00004000,
    shcne_updatedir = 0x00001000,
    shcne_updateimage = 0x00008000,
  }
  #endregion
}

希望本文所述对大家的c#程序设计有所帮助。