none
How to open in regedit a Folder and a DWORD (32-bit) value C# RRS feed

All replies

  • Hi Ahron321,

    Thanks for posting here.

    >> title

    This forum is about c++ development. For your case which is more related to C#, I will move this post to C# forum for better support.

    Thanks for your understanding and Cooperation.

    Best Wishes,

    Jack Zhang


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 22, 2018 2:01 AM
  • Hi Ahron321,

    It seems that you could achieve it by using RegistryKey 

    #Get folder

    RegistryKey localMachine = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64); //here you specify where exactly you want your entry
    
    // Get folder
    var reg = localMachine.OpenSubKey("Software\\Policies\\Microsoft\\Windows Defender\\Real-Time Protection", true);
    if (reg == null)
    {
    // add folder
       reg = localMachine.CreateSubKey("Software\\Policies\\Microsoft\\Windows Defender\\Real-Time Protection");
    }
    
    //Get DWord
    if (reg.GetValue("DisableRealtimeMonitoring") == null)
    {
    // Add DWord
        reg.SetValue("DisableRealtimeMonitoring", 1, RegistryValueKind.DWord);
    }


    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 22, 2018 7:49 AM
    Moderator
  • i have an error http://prntscr.com/l92hg5
    Monday, October 22, 2018 4:25 PM
  • Hi Ahron321,

    Please run the application as administrator.

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 23, 2018 1:09 AM
    Moderator