by Arvind (2 Submissions)
Category: Registry
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 2nd June 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Hides all the Desktop Items
API Declarations
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Const KEY_ALL_ACCESS = &HF3F 'Full access permission
Const HCU = &H80000001
Const subky = "Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
Dim handle As Long
Dim rval As Long
Dim result As Long
Me.Hide
rval = RegOpenKeyEx(HCU, subky, 0, KEY_ALL_ACCESS, handle)
'The following would Set the value to True i.e, Hide the desktop items on restart
rval = RegSetValueEx(handle, "NoDesktop", 0, 4, 1, 4)
'The following would Set the value to False i.e. delete the value
'rval = RegDeleteValue(handle, "NoDesktop")
rval = RegCreateKey(HCU, subky, handle)
rval = RegOpenKeyEx(HCU, subky, 0, KEY_ALL_ACCESS, handle)
rval = RegQueryValueEx(handle, "NoDesktop", 0, 4, result, 4)
rval = RegCloseKey(handle)
End Sub