Usuário com melhor resposta
regedit add e remove + setvalue c#

Pergunta
-
preciso adicionar e remover e setar valores no regedit C# vou da um exemplo
entrando no regedit
hkey_current_user/software/programa/ agora em programa vai ter um arquivo tipo programa
ae agora vamos setar o valor tipo "1" "10000" ou "valor com texto"
setvalue("programa", dados do valor"1") aviso não é a pasta /programa/ e sim o arquivo dentro dela programa
exemplo
mas vai ter um botão que vai fazer isso e vai modificar o valor tipo ta 0 ae clica no botao fica 1 i seria bom um jeito para escolher decimal e hexadecimal
espero que alguem possa me ajudar
Respostas
-
Z.s2,
Por favor, veja esse código:using Microsoft.Win32; using System; using System.Windows.Forms; namespace AcessandoRegistro { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.CreateSubKey("Software\\MSDN"); rk.SetValue("Name", "Visual Studio"); } private void button2_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.OpenSubKey("Software\\MSDN"); MessageBox.Show(rk.GetValue("Name").ToString()); } private void button3_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.OpenSubKey("Software\\MSDN", true); rk.SetValue("Name", "Visual Studio .NET 2005"); } private void button4_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.OpenSubKey("Software", true); rk.DeleteSubKeyTree("MSDN"); } private void button5_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.OpenSubKey("Software\\MSDN", true); rk.DeleteValue("Name"); } } }
========================================================
Título: MANIPULANDO O REGISTRO
Categoria:C# :: Codigo Fonte :: Registro do Windows
Compatibilidade: Visual Studio 2005
Dificuldade: Iniciante
Criado por: WEBER
Tamanho: 31,96 KB
Data de postagem: 16/06/2006 14:17:51
Status do arquivo: Manipulando o registro do windows
http://www.vbmania.com.br/index.php?modulo=detalhe&id=5208
========================================================
[]'s,
Fabio I.
Todas as Respostas
-
Z.s2,
Por favor, veja esse código:using Microsoft.Win32; using System; using System.Windows.Forms; namespace AcessandoRegistro { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.CreateSubKey("Software\\MSDN"); rk.SetValue("Name", "Visual Studio"); } private void button2_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.OpenSubKey("Software\\MSDN"); MessageBox.Show(rk.GetValue("Name").ToString()); } private void button3_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.OpenSubKey("Software\\MSDN", true); rk.SetValue("Name", "Visual Studio .NET 2005"); } private void button4_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.OpenSubKey("Software", true); rk.DeleteSubKeyTree("MSDN"); } private void button5_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.OpenSubKey("Software\\MSDN", true); rk.DeleteValue("Name"); } } }
========================================================
Título: MANIPULANDO O REGISTRO
Categoria:C# :: Codigo Fonte :: Registro do Windows
Compatibilidade: Visual Studio 2005
Dificuldade: Iniciante
Criado por: WEBER
Tamanho: 31,96 KB
Data de postagem: 16/06/2006 14:17:51
Status do arquivo: Manipulando o registro do windows
http://www.vbmania.com.br/index.php?modulo=detalhe&id=5208
========================================================
[]'s,
Fabio I. -