如何“刷新”以编程方式访问 Vista 开始菜单

发布于 2024-08-23 00:30:47 字数 276 浏览 8 评论 0 原文

我正在编写一段代码,用于删除用户开始菜单中的额外文件夹。我首先删除它包含的所有快捷方式,然后删除文件夹本身。

完成此操作后,我可以确认快捷方式已从开始菜单中删除,但它们包含的文件夹仍保留在开始菜单中列出。因此,我检查了文件系统中是否有这样的文件夹,但没有找到。我怀疑这是某种刷新问题,因此我注销了用户并重新登录到 Vista,发现该文件夹现在已从开始菜单列表中删除。

多么烦人...有谁知道如何以编程方式强制“刷新”Vista 开始菜单,以便用户在注销之前看不到这个空文件夹?

谢谢, -本

I am working on a piece of code that removes an extra folder we have in the user's start menu. I start by removing all of the shortcuts it contains, and then remove the folder itself.

After this is done, I can confirm that the shortcuts have been removed from the start menu, but their containing folder remains listed in the start menu. So, I checked the file system for such a folder and found none. Suspecting that this is some sort of refresh problem, I logged my user out and back into Vista and found that the folder was now removed from the start menu list.

How utterly annoying... Does anyone know how to programmatically force a 'refresh' of the Vista start menu, so that the user doesn't see this empty folder before they log out?

Thanks,
-Ben

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

来世叙缘 2024-08-30 00:30:47

我尝试自己实现这一点,但使用 SendMessageTimeout 并没有按预期工作。

相反,当我使用时它有效
SHGetSpecialFolderLocation(CSIDL_STARTMENU)
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, pidl, NULL);

有关示例 C++ 代码,请参阅这篇文章:
http://support.microsoft.com/kb/q193293/

在 Windows Server 2008 Enterprise 上测试(x86) 与 SP1。

I tried to implement this myself but it did not work as expected using SendMessageTimeout.

Instead, it worked when I used
SHGetSpecialFolderLocation(CSIDL_STARTMENU)
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, pidl, NULL);

See this article for sample c++ code:
http://support.microsoft.com/kb/q193293/

Tested on Windows Server 2008 Enterprise (x86) with SP1.

若有似无的小暗淡 2024-08-30 00:30:47

本文似乎有您正在寻找的答案:

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/ce540c7d-a113-4f39-956e-0af6bc91abd3/

给出的答案是:

class Program
 {
  [DllImport("user32.dll", SetLastError = true)]
  private static extern IntPtr SendMessageTimeout ( IntPtr hWnd, int Msg, IntPtr wParam, string lParam, uint fuFlags, uint uTimeout, IntPtr lpdwResult );

  private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
  private const int WM_SETTINGCHANGE = 0x1a;
  private const int SMTO_ABORTIFHUNG = 0x0002;

  static void Main ( string[] args )
  {
   SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
  }
 }

This article seems to have the answer you're looking for:

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/ce540c7d-a113-4f39-956e-0af6bc91abd3/

The answer given is:

class Program
 {
  [DllImport("user32.dll", SetLastError = true)]
  private static extern IntPtr SendMessageTimeout ( IntPtr hWnd, int Msg, IntPtr wParam, string lParam, uint fuFlags, uint uTimeout, IntPtr lpdwResult );

  private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
  private const int WM_SETTINGCHANGE = 0x1a;
  private const int SMTO_ABORTIFHUNG = 0x0002;

  static void Main ( string[] args )
  {
   SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
  }
 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文