C# 레지스트리에 값을 쓰고, 읽고, 삭제하기

2007/09/28 19:31

서비 .NET & WPF ,

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);                         
        }
    }
}
이 글의 관련글
  • TortoiseCVS 사용 시 Disk IO 성능 향상
  • finalize 메소드의 오버라이딩을 자제해야 하는 이유.
  • 손쉽게 파비콘( favicon.ico )을 만들어 봅시다. (4)
  • LINQPad를 이용하여 LINQ 편집하기 (1)
  • 넷빈즈 6.0 코드 템플릿 사용하기 :: NetBeans 6.0 Code Template
  • Java에 OpenID 적용 관련 아티클
  • String 타입의 날짜를 Date 타입으로 변환하기
  • Windows 2003 서버의 터미널서버 접속 하기
  • JAVA.UTIL.SCANNER로 텍스트 스캔하기
  • 2007/09/28 19:31 2007/09/28 19:31
    Trackback Address:http://www.yunsobi.com/blog/trackback/244
    [로그인][오픈아이디란?]