Solved

F5 - refresh problem

Posted on 1998-08-22
7
640 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

751 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