Private Sub CancellaChiaveDiRegistroValoreSpecifico(ByVal CartellaRoot As ValoriChiaveRegistro, ByVal PercorsoChiaveRegistro As String, ByVal ChiaveValore As String)
Dim regKey As Microsoft.Win32.RegistryKey = Nothing
Try
Select Case CartellaRoot
Case 0
regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(PercorsoChiaveRegistro, True)
Case 1
regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(PercorsoChiaveRegistro, True)
Case 2
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(PercorsoChiaveRegistro, True)
Case 3
regKey = Microsoft.Win32.Registry.Users.OpenSubKey(PercorsoChiaveRegistro, True)
Case 4
regKey = Microsoft.Win32.Registry.CurrentConfig.OpenSubKey(PercorsoChiaveRegistro, True)
Case 5
regKey = Microsoft.Win32.Registry.PerformanceData.OpenSubKey(PercorsoChiaveRegistro, True)
Case Else
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(PercorsoChiaveRegistro, True)
End Select
If regKey IsNot Nothing Then
regKey.DeleteValue(ChiaveValore)
End If
Catch ex As Exception
Finally
If regKey IsNot Nothing Then regKey.Close()
End Try
End Sub
Private Function CancellaSottoChiaveDiRegistroNew(ByVal CartellaRoot As ValoriChiaveRegistro, ByVal PercorsoChiaveRegistro As String) As Boolean
Try
Select Case CartellaRoot
Case 0
My.Computer.Registry.ClassesRoot.DeleteSubKey(PercorsoChiaveRegistro, True)
Case 1
My.Computer.Registry.CurrentUser.DeleteSubKey(PercorsoChiaveRegistro, True)
Case 2
My.Computer.Registry.LocalMachine.DeleteSubKey(PercorsoChiaveRegistro, True)
Case 3
My.Computer.Registry.Users.DeleteSubKey(PercorsoChiaveRegistro, True)
Case 4
My.Computer.Registry.CurrentConfig.DeleteSubKey(PercorsoChiaveRegistro, True)
Case 5
My.Computer.Registry.PerformanceData.DeleteSubKey(PercorsoChiaveRegistro, True)
Case Else
My.Computer.Registry.LocalMachine.DeleteSubKey(PercorsoChiaveRegistro, True)
End Select
Return True
Catch ex As Exception
Return False
End Try
End Function
Private Function CancellaChiaveDiRegistroValoreSpecificoNew(ByVal CartellaRoot As ValoriChiaveRegistro, ByVal PercorsoChiaveRegistro As String, ByVal ValoreChiave As String) As Boolean
Try
Select Case CartellaRoot
Case 0
My.Computer.Registry.ClassesRoot.OpenSubKey(PercorsoChiaveRegistro, True).DeleteValue(ValoreChiave, True)
Case 1
My.Computer.Registry.CurrentUser.OpenSubKey(PercorsoChiaveRegistro, True).DeleteValue(ValoreChiave, True)
Case 2
My.Computer.Registry.LocalMachine.OpenSubKey(PercorsoChiaveRegistro, True).DeleteValue(ValoreChiave, True)
Case 3
My.Computer.Registry.Users.OpenSubKey(PercorsoChiaveRegistro, True).DeleteValue(ValoreChiave, True)
Case 4
My.Computer.Registry.CurrentConfig.OpenSubKey(PercorsoChiaveRegistro, True).DeleteValue(ValoreChiave, True)
Case 5
My.Computer.Registry.PerformanceData.OpenSubKey(PercorsoChiaveRegistro, True).DeleteValue(ValoreChiave, True)
Case Else
My.Computer.Registry.LocalMachine.OpenSubKey(PercorsoChiaveRegistro, True).DeleteValue(ValoreChiave, True)
End Select
Return True
Catch ex As Exception
Return False
End Try
End Function