Categorias

Adicionar/Excluir e Ler Registro do Windows em C#, simples e direto.

Como disse, será simples é direto!


Gravar no Registro


string PATH = @"SOFTWAREQX3ROTASHosts";
RegistryKey registryKey = Registry.LocalMachine.CreateSubKey(PATH);
registryKey.SetValue("Servidor SMTP", "192.169.0.121:25");
registryKey.SetValue("Servidor POP", "192.169.0.121:110");
registryKey.Close();


Resgatar valor do mesmo.


RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(PATH);
Console.WriteLine(registryKey.GetValue("Servidor POP"));


Remover Chave do registro.

Registry.LocalMachine.DeleteSubKey(PATH);

Simples e direto!

[]’s
Francke Peixoto