Hỏi đáp

Chia sẻ kiến thức, cùng nhau phát triển

Làm thế nào để thay đổi file registry bằng windows form?

21:50 26-02-2022 475 lượt xem 3 bình luận

Mình muốn hỏi là làm thế nào để thay đổi file registry bằng windows form bằng cách bấm nút button
Mình cảm ơn rất nhiều !

Bình luận

Để bình luận, bạn cần đăng nhập bằng tài khoản Howkteam.

Đăng nhập
thanhnguyenit9x đã bình luận 13:53 02-03-2022

Bạn tham khảo ở đây nhé. Nên có true ở cuối nhé. Ví dụ:

RegistryKey myKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Company\\Compfolder", true);
if(myKey != null)    {
   myKey.SetValue("Deno", "1", RegistryValueKind.String);
   myKey.Close();
}
K9 SuperAdmin, KquizAdmin, KquizAuthor đã bình luận 08:29 01-03-2022

code ghi registry:

//opening the subkey  
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\OurSettings");  
              
//if it does exist, retrieve the stored values  
if (key != null)  
{  
    Console.WriteLine(key.GetValue("Setting1"));  
    Console.WriteLine(key.GetValue("Setting2"));  
    key.Close();  
} 

Bạn tham khảo thêm tại: thao tác registry

Câu hỏi mới nhất