How can I edit a registry key with VB.NET or VB6?

前端 未结 3 994
北荒
北荒 2021-01-20 16:40

I need to edit a registry key and set the data value to \"4\"

I know how to do it through the command prompt but am trying to find some Visual Basic code to do it.

3条回答
  •  轮回少年
    2021-01-20 17:10

    Here's how'd you do it in Visual Basic .NET

        Dim key As RegistryKey = Registry.LocalMachine
        Dim subkey As RegistryKey
    
    
        subkey = key.OpenSubKey("SYSTEM\CurrentControlSet\Services\USBSTOR", True)
    
        subkey.SetValue("Start", 4)
    

    You'll need to make sure to add

    Imports System
    Imports Microsoft.Win32
    

    at the top of your code.

提交回复
热议问题