![](/img/trans.png)
[英]Refresh Desktop in C# on Win7 like 'F5' would have been pressed to apply explorer settings
[英]How to refresh the windows desktop programmatically (i.e. F5) from C#?
是的,我知道这似乎是一个愚蠢的问题,它只是一次性的黑客我需要完成一个有点平凡的任务,所以我可以继续前进更有趣的事情。
编辑:也许更多的信息会有所帮助:我正在尝试从桌面删除一些快捷方式,我需要用户立即看到它被删除(所以他们不必按F5)。
您可以使用SHChangeNotify API。
[System.Runtime.InteropServices.DllImport("Shell32.dll")]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
然后以这种方式调用它
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
我想你正在寻找IActiveDesktop :: ApplyChanges 。 您需要通过COM接口访问它,使用Microsoft Interop上提供的所有文档应该相当容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.