Solved

F5 - refresh problem

Posted on 1998-08-22
7
649 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 17 hours left to enroll

623 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