如何从C#编程(即F5)刷新Windows桌面? [英] How to refresh the windows desktop programmatically (i.e. F5) from C#?

查看:110
本文介绍了如何从C#编程(即F5)刷新Windows桌面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我知道这似乎是一个愚蠢的问题,它只是一个一次性砍我需要换一个有点平凡的任务,这样我就可以转移到更有趣的东西。

Yeah, I know this seems like a dumb question, its just a one-off hack I need to wrap up a somewhat mundane task so I can move on to something more interesting.

编辑: 也许更多的信息将帮助:我试图从桌面上删除了一些快捷方式,我需要用户看到它去掉马上(这样他们就不必preSS F5)

Maybe more info would help: I'm trying to remove some shortcuts from the desktop and I need the user to see it removed right away (so they don't have to press F5).

推荐答案

您可以使用SHChangeNotify API。

You can use the SHChangeNotify API.

[System.Runtime.InteropServices.DllImport("Shell32.dll")]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);

然后调用它这样

and then call it this way

SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);

这篇关于如何从C#编程(即F5)刷新Windows桌面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆