using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Win32;
public static class Utils
{
public static IDictionary GetUserRegistry(string key)
{
Dictionary result = null;
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(key);
if (registryKey != null)
{
result = new Dictionary();
foreach (string name in registryKey.GetValueNames())
{
result.Add(name, registryKey.GetValue(name));
}
registryKey.Close();
}
return result;
}
public static void SetUserRegistry(string key, IDictionary pairs)
{
RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(key);
if (registryKey == null)
{
throw new Exception("cannot create registry key: " + key);
}
foreach (string name in pairs.Keys)
{
registryKey.SetValue(name, pairs[name]);
}
registryKey.Close();
}
}