Community discussion forum

Boot RegKey API

This is a comment thread discussing Boot RegKey API
  • 9 years ago

    This thread is for discussions of Boot RegKey API.

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 6 years ago

    Didn't work for me......

  • 5 years ago

    I'm using code like this by VB6 and it works perfect but not by VB.NET. Why?


    Option Explicit
      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 RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
       
    Private Sub Command1Click()
       Const REG
    SZ As Long = 1
       Const HKEYLOCALMACHINE = &H80000002
       Const KEYSETVALUE = &H2
       Dim sKeyName As String
       Dim lRetVal As Long
       Dim hregKey As Long
       sKeyName = "SOFTWARE\Wiesemann & Theis\Com-server\Com2"
       
           lRetVal = RegOpenKeyEx(HKEYLOCALMACHINE, sKeyName, 0, KEYSETVALUE, hregKey)
           
       Dim lValueType As Long
       Dim vValueSetting As String
       Dim sValueName As String
       
           sValueName = "IpAddress"
           lValueType = REG_SZ
           vValueSetting = "123.45.67.89" & Chr$(0)
           lRetVal = RegSetValueEx(hregKey, sValueName, 0, lValueType, vValueSetting, Len(vValueSetting))
           RegCloseKey (hregKey)
    End Sub

  • 5 years ago

    You no longer need to use API to access the registry in VB.NET. Instead, take a look at the Microsoft.Win32 namespace, which contains Registry functions. For example,


    RegistryKey myKey = Registry.LocalMachine.OpenSubKey("Software\MySoftware");
    MessageBox.Show (webZincKey.GetValue("Serial").ToString());


    displays a message box displaying the value of the Serial item in the HKEYLOCALMACHINE\Software\MySoftware key.

  • 5 years ago

    Thanks for Your advise.

  • 2 years ago

    Works Great but
    Can someone show me how to delete a reg Key?




  • 2 years ago

    I tried something yesterday but instead of deleting the one value I deleted the whole key!
    oops please can somebody give the right code?


Post a reply

Enter your message below

Sign in or Join us (it's free).