?
Solved

Force Registry to update

Posted on 2003-03-15
17
Medium Priority
?
999 Views
Last Modified: 2012-06-27
I have a program in which I want a button to toggle on/off the showing of hidden files/folders.

I know to do this I just need change the value of:

HKCU\Software\Microsoft\windows\currentversion\Explorer\Advanced\Hidden

If an open folder has hidden files/folders the hidden files/folders do not disappear/appear until I choose View->Refresh or press F5.

Is there a way that I can make it programatically refresh?
0
Comment
Question by:moterk
[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
  • 4
  • 3
  • 3
  • +5
17 Comments
 
LVL 4

Expert Comment

by:iozturk
ID: 8144781
set WshShell = WScript.CreateObject ("WScript.Shell")

WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\", 1, "REG_BINARY")
WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader", "Goocher!", "REG_SZ")

set bKey =    WshShell.RegRead ("HKCU\\Software\\ACME\\FortuneTeller\\")
WScript.Echo (WshShell.RegRead ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader"))

WshShell.RegDelete ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader")
WshShell.RegDelete ("HKCU\\Software\\ACME\\FortuneTeller\\")
WshShell.RegDelete ("HKCU\\Software\\ACME\\")
0
 
LVL 4

Expert Comment

by:iozturk
ID: 8144812
So sory, I copy and paste from jscript the code should look like

Dim WshShell

Set WshShell = CreateObject("WScript.Shell")

WshShell.RegWrite "HKCU\Software\ACME\FortuneTeller\", 1, "REG_BINARY"
WshShell.RegWrite "HKCU\Software\ACME\FortuneTeller\MindReader", "Goocher!", "REG_SZ"

bkey = WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\")
MsgBox WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\MindReader")

WshShell.RegDelete ("HKCU\Software\ACME\FortuneTeller\MindReader")
WshShell.RegDelete ("HKCU\Software\ACME\FortuneTeller\")
WshShell.RegDelete ("HKCU\Software\ACME\")

0
 
LVL 4

Expert Comment

by:iozturk
ID: 8144838
If you want this code run on WinNT 4 windows scripting host should be installed otherwise you should use windows API's.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:moterk
ID: 8144888
I am sorry iozturk but I do not see what you comment has to do with my question "Is there a way that I can make it programatically refresh?"
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8145744
Maybe you need this too (after do the change to registry)

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
private Const HWND_BROADCAST = &HFFFF&
private Const WM_WININICHANGE = &H1A


Public Sub Anounce_locale_change()
PostMessage HWND_BROADCAST, WM_WININICHANGE, 0, 0
End Sub
0
 

Author Comment

by:moterk
ID: 8170212
I had already tried:

SendMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0

Now because of Richie's suggestion I tried

PostMessage HWND_BROADCAST, WM_WININICHANGE, 0, 0
SendMessage HWND_BROADCAST, WM_WININICHANGE, 0, 0
PostMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0

None of these work either.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8170248
Are you working with XP?
Also, take in mind that Explorer.exe re-scan the folder to show them again with new attributes.
0
 

Author Comment

by:moterk
ID: 8170420
Yes I am working with XP but I would like it to work with older Windows OS as well (if possible).

What do you mean by "take in mind that Explorer.exe re-scan the folder to show them again with new attributes"

I know I can do a View->Refresh or press F5 in explorer but I want the refresh to be automatic, so that my program's user can see that something happened.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8171299
I meant, even explorer.exe re-scan the folder to refresh the view with new folders attributes (maybe don't you see it but it is what it does).
So, taking this in mind, you could use a dirty/cheap solution.
Locate explorer window and do:
sendkeys "{F5}"
0
 

Author Comment

by:moterk
ID: 8174279
There may not be an open explorer window.  But if they have hidden files or folders on the desktop they should show up or disappear as soon as the user clicks the "Show" or the "Hide" button.

0
 

Expert Comment

by:CleanupPing
ID: 8900039
moterk:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 3

Expert Comment

by:Kalimac55
ID: 9063265
You have to use SendMessage and not PostMessage! The below code works fine for me..

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HWND_BROADCAST = &HFFFF&
Private Const WM_SETTINGCHANGE = &H1A


SendMessage HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0

In case you are still interested.
0
 
LVL 3

Expert Comment

by:Kalimac55
ID: 9063290
And of course a more decent test proved that did not work either. Sorry.
0
 

Expert Comment

by:scottzz
ID: 9207199

moterk - do you still need help with this?

I have it working in VB, but need to polish it up before posting.  

Let me know,
-Scott

0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9441204
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Split between Richie_Simonetti and Kalimac55

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9441207
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->PAQ - no points refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER

GPrentice00
Cleanup Volunteer
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9495979
This question is PAQed and no points refunded (of 500)

YensidMod
Expert Exchange Moderator
0

Featured Post

Technology Partners: 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

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…
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…
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 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…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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