none
force update/refresh of windows start menu RRS feed

  • Question

  • I am writing a C# application to lock down features within the Windows OS.  I have identified some registry keys that will allow me to remove menus from the windows start menu such as documents, run, search, etc. 

     

    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
    "NoRecentDocsMenu"=dword:00000001[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
    "NoSMHelp"=dword:00000001

    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
    "NoSMMyDocs"=dword:00000001[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
    "NoFind"=dword:00000001

    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
    "NoRun"=dword:00000001

     

    The problem I am encountering is that I can not find a way to force the OS to refresh its start menu after the change has taken place in the registry without having to log off and log back on. 

     

    I have been reading a lot of material about SHChangeNotify, but have not figured out how to effectively use it to force an update.  Apparently SHChangeNotify allows you to notify the explorer shell of any changes that have taken affect in the OS.  I have read (http://findarticles.com/p/articles/mi_zdpcm/is_199909/ai_ziff8123/pg_6) that SHCNE_ASSOCCHANGED has a side effect of flushing the start menu cache, but I have not succeeded in accomplishing this.  

     

    Does anyone know how to force a refresh of the start menu? 

     

    I know there is a way to accomplish this...I have downloaded some third-party apps that are doing it, but they don't have all the functionality I need.  This effect is also seen when a user right clicks on the start menu > properties > makes a change and hits apply.  I should also mention that I do not wish to stop explorer.exe and restart it to force the update.

     

    Any help is greatly appreciated.  Thanks in advance.

     

    Aaron

    Friday, October 19, 2007 11:13 PM

Answers

  • You could try broadcasting a WM_SETTINGCHANGE message.  For example:

    Code Block

     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);
      }
     }

     

     

    Saturday, October 20, 2007 3:16 PM

All replies

  • You could try broadcasting a WM_SETTINGCHANGE message.  For example:

    Code Block

     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);
      }
     }

     

     

    Saturday, October 20, 2007 3:16 PM
  • Moved to WinForms forum.  Please reserve the C# Language forum for questions specifically related to the C# language such as keywords, language features and learning C#.

     

    Sunday, October 21, 2007 8:38 PM
  • Your solution worked beautifully....thanks a lot.

    Aaron
    Monday, October 22, 2007 3:49 PM