반응형

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32; // 레지스트리관련 클래스를 쓰기위해 추가

namespace regiEx1
{
class Program
{
static void Main(string[] args)
{
string regSubkey = "Software\\myTestKey";
// 서브키를 얻어온다. 없으면 null
RegistryKey rk = Registry.LocalMachine.OpenSubKey(regSubkey, true);
// 없으면 서브키를 만든다.
if (rk == null)
{
// 해당이름으로 서브키 생성
rk = Registry.LocalMachine.CreateSubKey(regSubkey);
}
string[] strData = new string[] {"aaa","bbb","ccc"};
// 서브키 아래 값 쓰기
rk.SetValue("test", strData);
// 서브키 아래 값 읽기
string[] regStr = rk.GetValue("test") as string[];

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

// 서브키 삭제
Registry.LocalMachine.DeleteSubKey(regSubkey);
}
}
}

반응형

+ Recent posts