0

can somebody help me convert this code to an another c# code ?:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\csgo.exe\PerfOptions]
"CpuPriorityClass"=dword:00000003

I don't understand about it, i try many ways but it often catches error so I post this question to find help! Tks

Flydog57
  • 6,851
  • 2
  • 17
  • 18
  • 1
    Does this answer your question? [Writing to registry in a C# application](https://stackoverflow.com/questions/7230102/writing-to-registry-in-a-c-sharp-application) – Pavel Anikhouski Jun 23 '20 at 13:57

1 Answers1

0

You can use Registry and RegistryKey classes:

using (var registryKey = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\csgo.exe\\PerfOptions"))
{
    if (registryKey != null)
    {
        var cpuPriorityClass = registryKey.GetValue("CpuPriorityClass"); // read value

        // or

        registryKey.SetValue("CpuPriorityClass", 3, RegistryValueKind.DWord); // set value
    }
}
Roman
  • 11,966
  • 10
  • 38
  • 47