Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

I'm writing a simple program that will show or hide the icons on the desktop without any user interaction (they simply run it). The reason I am doing this is to show/hide icons by using a link to the app that is always visible on the taskbar rather than have to right click on the desktop everytime. I'm just wondering how I can tell Windows that the value of the registry key that it uses to determine if icons hide or not has changed...

 

Here is the registry information it alters (works in XP, and might in NT or 2000):

 

Hive: HKEY_CURRENT_USER

Key: Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced

Name: HideIcons

Type: REG_DWORD

Value: 0

 

And here is the working code I have... it just needs to have the refresh part added:

 

Dim rkey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", True)
Dim ValueNames As String()
Dim ValueName As String
Dim Value As Integer

ValueNames = rkey.GetValueNames

For Each ValueName In ValueNames
   If (ValueName = "HideIcons") Then
       If (rkey.GetValue("HideIcons") = 0) Then
           Value = 1
           rkey.SetValue("HideIcons", Value)
       ElseIf (rkey.GetValue("HideIcons") = 1) Then
           Value = 0
           rkey.SetValue("HideIcons", Value)
       End If
   End If
Next

rkey.Close()

Posted
I just tried my application, and if you go run it and then go into the Desktop Properties menu and click on another wallpaper and then reselect the existing wallpaper (so the APPLY button is clickable) and click the button, the desktop refreshes and the icons disappear or appear like they should. The problem know is how do I get that to occur after the registry key is changed programmatically?
  • *Experts*
Posted

I dont have time to test it right now :) but you could try invalidating the desktop window with these APIs:

Declare Function RedrawWindow Lib "user32" Alias "RedrawWindow" (ByVal hwnd As Integer, lprcUpdate As RECT, ByVal hrgnUpdate As INTEGER, ByVal fuRedraw As Integer) As Integer
'and
Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Integer

http://www.mentalis.org/apilist/RedrawWindow.shtml

http://www.mentalis.org/apilist/GetDesktopWindow.shtml

Posted
Ahh, nice try, but it still didn''t work. C++ has this thing called IActiveDesktop that allows you to refresh the entire desktop by simply using the ApplyChanges method. Does anyone know if this will work in VB.NET??? I'm looking into it, but I can't seem to find anything about using it in VB.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...