VB.Net by API/Microsoft.Win32/Registry

Материал из VB Эксперт
Перейти к: навигация, поиск

Registry.CurrentUser

  
Option Strict On
Imports Microsoft.Win32
Public Module Tester
   Public Sub Main
      Dim regKey As RegistryKey
      Dim keyTop As RegistryKey = Registry.CurrentUser
      regKey = keyTop.OpenSubkey("Software\MyCompany\MyApp", True)
      If regKey Is Nothing Then
         regKey = keyTop.CreateSubKey("Software\MyCompany\MyApp")
      End If
      Dim binValue As Byte() = {&HF0, &HFF, &H12, &HE0, &H43, &HAC}
      Dim strngValue As String() = {"A", "B","C", "D"}
      "regKey.SetValue("WindowState", 0, RegistryValueKind.DWord)
      "regKey.SetValue("CustomWindowCaption", "Client Contact Management",RegistryValueKind.String)
      "regKey.SetValue("CustomPosition", binValue, RegistryValueKind.Binary)
      "regKey.SetValue("CustomLabels", strngValue, RegistryValueKind.MultiString)
   End Sub
End Module


Registry.GetValue

  
public class Test
   public Shared Sub Main
        Console.WriteLine(My.ruputer.Registry.GetValue("HKEY_CURRENT_USER\Software\yourname\subname\","PromptOnExit", "0"))
   End Sub
End Class


Registry.SetValue

  
Option Strict On
Imports Microsoft.Win32
Public Module RegistrySetValue
   Public Sub Main
      Dim regData As Byte() = {&HF0, &HFF, &H20, &H00}
      Dim regTopKey As String = "HKEY_LOCAL_MACHINE"
      Dim regPath As String = "\Software\MyCompany\MyApp"
"      Registry.SetValue(regTopKey & regPath, "BinData", regData, RegistryValueKind.Binary)
   End Sub
End Module