Force Desktop Refresh?

This is a discussion on Force Desktop Refresh? within the C# Programming forums, part of the General Programming Boards category; I have an app that installs some shortcuts on the desktop, however they don't show up until you manually hit ...

  1. #1
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571

    Force Desktop Refresh?

    I have an app that installs some shortcuts on the desktop, however they don't show up until you manually hit F5 to refresh the desktop.

    How can I force the desktop to refresh in C#?
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    54
    IActiveDesktop::ApplyChanges, if you can use it from C#

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Possibly use Pinvoke????

    Code:
    using System;
    using System.Runtime.InteropServices;
    
    class RefreshDesktop
    {
        public enum SHCNE : uint
        {
            SHCNE_RENAMEITEM = 0x00000001, 
                SHCNE_CREATE = 0x00000002, 
                SHCNE_DELETE = 0x00000004, 
                SHCNE_MKDIR = 0x00000008, 
                SHCNE_RMDIR = 0x00000010,
                SHCNE_MEDIAINSERTED = 0x00000020,
                SHCNE_MEDIAREMOVED = 0x00000040,
                SHCNE_DRIVEREMOVED = 0x00000080,
                SHCNE_DRIVEADD = 0x00000100,
                SHCNE_NETSHARE = 0x00000200,
                SHCNE_NETUNSHARE = 0x00000400,
                SHCNE_ATTRIBUTES = 0x00000800,
                SHCNE_UPDATEDIR = 0x00001000,
                SHCNE_UPDATEITEM = 0x00002000, 
                SHCNE_SERVERDISCONNECT = 0x00004000,
                SHCNE_UPDATEIMAGE = 0x00008000,
                SHCNE_DRIVEADDGUI = 0x00010000,
                SHCNE_RENAMEFOLDER = 0x00020000,
                SHCNE_FREESPACE = 0x00040000,
                SHCNE_EXTENDED_EVENT = 0x04000000,
                SHCNE_ASSOCCHANGED = 0x08000000,
                SHCNE_DISKEVENTS = 0x0002381F,
                SHCNE_GLOBALEVENTS = 0x0C0581E0,
                SHCNE_ALLEVENTS = 0x7FFFFFFF,
                SHCNE_INTERRUPT = 0x80000000
        }
        public enum SHCNF  : uint
        {
            SHCNF_IDLIST = 0x0000,
                SHCNF_PATHA = 0x0001, 
                SHCNF_PRINTERA = 0x0002,
                SHCNF_DWORD = 0x0003,
                SHCNF_PATHW = 0x0005,
                SHCNF_PRINTERW = 0x0006,
                SHCNF_TYPE = 0x00FF,
                SHCNF_FLUSH = 0x1000,
                SHCNF_FLUSHNOWAIT = 0x2000
        }
        [DllImport("shell32.dll", CharSet = CharSet.Auto)]
            public static extern void SHChangeNotify(UInt32 wEventId, UInt32 uFlags, IntPtr dwItem1, IntPtr dwItem2); 
    
        public static void Main() 
        {
             SHChangeNotify((uint)SHCNE.SHCNE_ASSOCCHANGED, (uint)SHCNF.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);
       }
    }

  4. #4
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Thanks, I'm sure one of those (or both) should work

    Yup, got it working, thanks!
    Last edited by Cat; 09-06-2008 at 11:06 AM.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. repainting desktop window on refresh
    By ave in forum Windows Programming
    Replies: 14
    Last Post: 07-17-2008, 07:47 PM
  2. Getting Icons from the Desktop
    By Mastadex in forum Windows Programming
    Replies: 6
    Last Post: 08-29-2007, 04:33 PM
  3. ListView Refresh, Update
    By de4th in forum C++ Programming
    Replies: 1
    Last Post: 12-23-2006, 08:13 AM
  4. Showing Desktop SW_DEFAULT
    By Yuri in forum Windows Programming
    Replies: 6
    Last Post: 11-20-2005, 12:28 PM
  5. curses problem
    By rajesh23 in forum Linux Programming
    Replies: 2
    Last Post: 10-07-2003, 07:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21