IT/C#

레지스트리에 내용 쓰기

lI헐헐Il 2012. 6. 29. 17:41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;

namespace Registry_Handle
{
    class Program
    {
        static void Main(string[] args)
        {
            string regSubKey = "Software\\myTestKey";

            RegistryKey rk = Registry.LocalMachine.OpenSubKey(regSubKey, true);

            if (rk == null)
            {
                rk = Registry.LocalMachine.CreateSubKey(regSubKey);
                
            }
            
            string[] strData = new string[] { "aaa", "bbb", "ccc" };    
            rk.SetValue("asdfqwer", strData);
            string[] regStr = rk.GetValue("asdfqwer") as string[];

            Console.WriteLine(regStr[1]);
            Console.ReadLine();

            Registry.LocalMachine.DeleteSubKey(regSubKey);
        }
    }
}