반응형
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);
}
}
}
반응형
'Program > C#' 카테고리의 다른 글
파일 백업 툴 FileSyncer (0) | 2011.03.24 |
---|---|
레지스트리 값 읽고, 쓰기 방법 2 (0) | 2011.03.24 |
C#에서 C++ DLL의 Call by Referance out 인수 사용하는 방법 (0) | 2011.03.24 |
C#에서 Win32 API 사용하기2 (0) | 2011.03.24 |
웹페이지 자동로그인 구현 (0) | 2011.03.24 |