48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Win32;
|
|
|
|
namespace Vichingo455_Settings.Utilities
|
|
{
|
|
internal class RegistryWorker
|
|
{
|
|
/// <summary>
|
|
/// Sets a registry value on the local machine
|
|
/// </summary>
|
|
/// <param name="RegistryKey">Registry Key</param>
|
|
/// <param name="RegistryValueName">Registry Value Name</param>
|
|
/// <param name="RegistryValueData">Registry Value Data</param>
|
|
/// <param name="RegistryValueType">Registry Value Type</param>
|
|
/// <returns></returns>
|
|
public static int SetRegistryValueLocalMachineA(string RegistryKey,string RegistryValueName, string RegistryValueData, RegistryValueKind RegistryValueType)
|
|
{
|
|
try
|
|
{
|
|
RegistryKey rk = Registry.LocalMachine.CreateSubKey(RegistryKey);
|
|
rk.SetValue(RegistryValueName,RegistryValueData,RegistryValueType);
|
|
return 0;
|
|
}
|
|
catch
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
public static int SetRegistryValueCurrentUserA(string RegistryKey, string RegistryValueName, string RegistryValueData, RegistryValueKind RegistryValueType)
|
|
{
|
|
try
|
|
{
|
|
RegistryKey rk = Registry.CurrentUser.CreateSubKey(RegistryKey);
|
|
rk.SetValue(RegistryValueName, RegistryValueData, RegistryValueType);
|
|
return 0;
|
|
}
|
|
catch
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|