I'm new to VB.Net, and VB Forums, this is a project for work and I don't get why its not acting correctly. Its supposed to write a value to the registry to restrict certain aspects of the user interface. I wrote this as a mini-proj on how to use the registry. Am I doing this right?

Imports System
Imports Microsoft.Win32

Module Module1
Sub Main()
'Registry Roots
Dim HKCR As RegistryKey = Registry.ClassesRoot 'HKEY_CLASSES_ROOT
Dim HKCC As RegistryKey = Registry.CurrentConfig 'HKEY_CURRENT_CONFIG
Dim HKCU As RegistryKey = Registry.CurrentUser 'HKEY_CURRENT_USER
Dim HKLM As RegistryKey = Registry.LocalMachine 'HKEY_LOCAL_MACHINE
Dim HKU As RegistryKey = Registry.Users 'HKEY_USERS

'subkeys to write to
Const CU_SOFT_POL As String = "SOFTWARE\MICROSOFT\WINDOWS\POLICIES"
Const CU_WIN_POL As String = "SOFTWARE\POLICIES"
Const LM_SOFT_POL As String = "SOFTWARE\POLICIES"
Const LM_WIN_POL As String = "SOFTWARE\MICROSOFT\WINDOWS\POLICIES"
Const Explorer As String = "\EXPLORER"

'reg entries
Const NoTaskbarContextMenu = "NoTrayContextMenu"

Dim KeyName As String
Dim x As Integer

x = 1 '
KeyName = CU_SOFT_POL & Explorer
HKCU.OpenSubKey(KeyName, True)
HKCU.SetValue(KeyName & "\" & NoTaskbarContextMenu, x)
HKCU.Close()

End Sub
End Module


Thanks for any help.