Solved

F5 - refresh problem

Posted on 1998-08-22
7
623 Views
Last Modified: 2008-02-01
i want to send F5 - refresh to the desktop of windows.
i changed the registry, and i want the desktop to be updated. i don't have a clue how to do that.
tried setactivewindow, getdesktopwindow... anything.
i need this to work under NT and 95
0
Comment
Question by:msiman
7 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1430408
ShChangeNotify as in this example from Brad Martinez:


With this...

' Notifies the system that something was changed in the shell. The
' system then notifies all app's registered to be notified of such changes.
Declare Sub SHChangeNotify Lib "shell32" _
                        (ByVal wEventId As Long, _
                        ByVal uFlags As Long, _
                        ByVal dwItem1 As Any, _
                        ByVal dwItem2 As Any)

' wEventId value indicating that the contents of an existing folder
' have changed, but the folder still exists and has not been renamed.
Public Const SHCNE_UPDATEDIR = &H1000          

' uFlags value specifying that the dwItem1 and dwItem2 params
' are pidls (pointers to item ID lists).
Public Const  SHCNF_IDLIST = &H0

' Retrieves the location (it's pidl) of a special system folder.
' Returns NOERROR if successful or an OLE-defined error result otherwise.
Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
                              (ByVal hwndOwner As Long, _
                              ByVal nFolder As Long, _
                              pidl As Long) As Long

' nFolder value specifying to retrieve the desktop folder's pidl.
Public Const CSIDL_DESKTOP = &H0

' Indicates a successful HRESULT, same as S_OK
Public Const NOERROR = 0

' Frees memory allocated by the shell (pidls).
Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)

And the wrapper...

' Updates the contents of the shell folder specified by nFolder.
' Returns True if successful, False otherwise.

Public Function UpdateShellFolder(nFolder As Long) As Boolean
  Dim pidl As Long
 
  If (SHGetSpecialFolderLocation(0, nFolder, pidl) = NOERROR) Then
    Call SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, pidl, pidl)
    ' Free the memory the shell allocated for the pidl
    Call CoTaskMemFree(pidl)
    UpdateShellFolder = True
  End If

End Function



0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1430409
PS:There should be a demo here:
http://members.aol.com/btmtz/vb/shnotify/index.htm

Michel
0
 
LVL 2

Author Comment

by:msiman
ID: 1430410
it just doesn't work.
i chanegd the name of "My Computer" in the registery, ran this code, and the icon didn't update....

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1430411
Sorry to hear it - I do not have VB so I cannot test it myself, I'm afraid.

Could it have something to do with My Computer being a somewhat special folder that does not get changed so easily? Could you change or create another folder, perhaps?

Michel
0
 
LVL 1

Expert Comment

by:cvidler
ID: 1430412
Find the window name of the desktop and use SendKeys() to send the F5 key to the desktop window. I think you'll have to use FindWindow API to get teh hWnd of the desktop (a listview control!!)
0
 
LVL 2

Author Comment

by:msiman
ID: 1430413
the desktop has no TITLE
0
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1430414
use the following code :

Private Const HWND_BROADCAST = &HFFFF&
Private Const WM_SETTINGCHANGE = &H1A 'same as the old WM_WININICHANGE

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now