C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-05-2008, 08:19 PM   #1
Cat
Registered User
 
Join Date: May 2003
Posts: 1,199
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.
Cat is offline   Reply With Quote
Old 09-06-2008, 08:52 AM   #2
Registered User
 
Join Date: Feb 2006
Posts: 54
IActiveDesktop::ApplyChanges, if you can use it from C#
Doodle77 is offline   Reply With Quote
Old 09-06-2008, 09:36 AM   #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);
   }
}
BobS0327 is offline   Reply With Quote
Old 09-06-2008, 10:51 AM   #4
Cat
Registered User
 
Join Date: May 2003
Posts: 1,199
Thanks, I'm sure one of those (or both) should work

Yup, got it working, thanks!
__________________
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.

Last edited by Cat; 09-06-2008 at 11:06 AM.
Cat is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 09:53 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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