Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. ---------------REG_FUNCT_OLD
  2. ---------------------------------------
  3.  
  4. Imports Microsoft.Win32
  5. Public Class Reg_Funcs
  6. Public Shared Function Write_Reg(ByVal Branch As String, ByVal Key As String, ByVal Val As String, Optional ByVal overwrite As Boolean = False) As Boolean
  7. Write_Reg = False
  8. Dim RK As RegistryKey
  9. RK = Registry.CurrentUser.OpenSubKey(Branch, True)
  10. If RegKey_Exists(Branch, Key) = False Then
  11. RK.SetValue(Key, Val)
  12. Write_Reg = True
  13. Else
  14. If overwrite = True Then
  15. RK.SetValue(Key, Val)
  16. Write_Reg = True
  17. Else
  18. Write_Reg = False
  19. End If
  20. End If
  21. RK.Close()
  22. End Function
  23. Public Shared Function Delete_Reg(ByVal Branch As String, ByVal Key As String) As Boolean
  24. Delete_Reg = False
  25. Dim RK As RegistryKey
  26. If RegKey_Exists(Branch, Key) = True Then
  27. RK = Registry.CurrentUser.OpenSubKey(Branch, True)
  28. RK.DeleteValue(Key)
  29. RK.Close()
  30. Delete_Reg = True
  31. Else
  32. Delete_Reg = False
  33. End If
  34. End Function
  35. Public Shared Function Read_Reg(ByVal Branch As String, ByVal Key As String) As String
  36. Read_Reg = ""
  37. Dim RK As RegistryKey
  38. RK = Registry.CurrentUser.OpenSubKey(Branch, True)
  39. If RegKey_Exists(Branch, Key) = True Then
  40. Read_Reg = RK.GetValue(Key)
  41. Else
  42. Read_Reg = ""
  43. End If
  44. RK.Close()
  45. End Function
  46. Public Shared Function RegKey_Exists(ByVal Branch As String, ByVal Key As String) As Boolean
  47. RegKey_Exists = False
  48. Dim RK As RegistryKey
  49. RK = Registry.CurrentUser.OpenSubKey(Branch, True)
  50. If Not RK.GetValue(Key) = "" Then
  51. RegKey_Exists = True
  52. Else
  53. RegKey_Exists = False
  54. End If
  55. RK.Close()
  56. End Function
  57. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement