Solved

F5 - refresh problem

Posted on 1998-08-22
7
618 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

760 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

21 Experts available now in Live!

Get 1:1 Help Now