Solved

F5 - refresh problem

Posted on 1998-08-22
7
628 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 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