讀取建立登入檔

static void createRegistryKey(string item, string content)
{
RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Test1111", true);
if( rk==null )
{
rk = Registry.LocalMachine.OpenSubKey("SOFTWARE", true).CreateSubKey("Test1111");
}

rk.SetValue(item, content);

rk.Close();
rk = null;
}
static string readRegistryKey(string item)
{
RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Test1111", true);

if (rk == null)
return "";

string st = rk.GetValue(item).ToString();

if (st ==null)
st = "";

rk.Close();
rk = null;
return st;
}

留言

熱門文章