Option Explicit
Dim msg As String
Private Const REG_DWORD As Long = 4
Private Const HKEY_CURRENT_USER = &H80000001
Private Const KEY_ALL_ACCESS = &H3F
Private Const REG_OPTION_NON_VOLATILE = 0
Private Declare Function RegCloseKey Lib “advapi32.dll” _
(ByVal hKey As Long) As Long
Private Declare Function RegOpenKeyEx Lib “advapi32.dll” _
Alias “RegOpenKeyExA” (ByVal hKey As Long, ByVal lpSubKey _
As String, _ByVal ulOptions As Long, ByVal samDesired As Long,_ phkResult As Long) As Long
Private Declare Function RegSetValueExLong Lib _
“advapi32.dll” Alias “RegSetValueExA” (ByVal hKey As Long,_
ByVal lpValueName As String,ByVal Reserved As Long, _
ByVal dwType As Long, lpValue As Long,ByVal cbData As Long) As Long
Private Sub cmdfav_Click()
SetKeyValue “Software\Microsoft\Windows\Currentversion\policies\explorer”, “NoFavoritesMenu”, 1, REG_DWORD
msg = MsgBox(“You need to restart Windows for the changes to take place.”, vbCritical, “Restart Windows”)
End Sub
‘This is to hide the desktop icons
Private Sub cmdhide_Click()
SetKeyValue “Software\Microsoft\Windows\Currentversion\policies\explorer”, “NoDesktop”, 1, REG_DWORD
msg = MsgBox(“You need to restart Windows for the changes to take place.”, vbCritical, “Restart Windows”)
End Sub
‘This is to disable the shut down windows option
Private Sub cmdshut_Click()
SetKeyValue “Software\Microsoft\Windows\Currentversion\policies\explorer”, “NoClose”, 1, REG_DWORD
msg = MsgBox(“You need to restart Windows for the changes to take place.”, vbCritical, “Restart Windows”)
End Sub
‘This is to unhide the desktop icons
Private Sub cmdunhide_Click()
SetKeyValue “Software\Microsoft\Windows\Currentversion\policies\explorer”, “NoDesktop”, 0, REG_DWORD
msg = MsgBox(“You need to restart Windows for the changes to take place.”, vbCritical, “Restart Windows”)
End Sub
Public Function SetValueEx(ByVal hKey As Long, sValueName As String,lType As Long, vValue As Variant) As Long
Dim lValue As Long
Dim sValue As String
Select Case lType
Case REG_DWORD
lValue = vValue
SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, _
lType, lValue, 4)
End Select
End Function
Private Sub SetKeyValue(sKeyName As String, sValueName As String,vValueSetting As Variant, lValueType As Long)
Dim lRetVal As Long
Dim hKey As Long
lRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, sKeyName, 0, _
KEY_ALL_ACCESS, hKey)
lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)
RegCloseKey (hKey)
End Sub
(sumber:www.freevbcode.com)