Usuário com melhor resposta
Problema com registro do wm6 no csharp

Pergunta
-
Olá pessoal, estou com um problema na hora de trazer dados do registro chega uma parte do codigo q ele traz nulo nao sei porque veja o código:
Eu já fiz o mesmo codigo em vb.net e funcionou tudo corretamente sem erro nenhum por favor se alguem puder me ajudar obrigado.
RegistryKey pRegKey = Registry.LocalMachine; pRegKey = pRegKey.OpenSubKey("Software", true); pRegKey = pRegKey.OpenSubKey("Mobile", true); pRegKey = pRegKey.OpenSubKey("PalmVistoria", true);//Nessa parte ele traz nulo mesmo existindo essa subkey no registro
string val = Convert.ToString(pRegKey.GetValue("PrimeiroUso")); if (val == "sim") { btnEntrar.Enabled = false; } else{ btnEntrar.Enabled = true; }
- Movido AndreAlvesLimaModerator sexta-feira, 17 de dezembro de 2010 12:20 (De:C#)
Respostas
-
segue um exemplo que eu uso..
public string Read(string KeyName) { Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine; Microsoft.Win32.RegistryKey sk = rk.OpenSubKey("SOFTWARE\\NOME_DA_SUA_APLICACAO"); if (sk == null) { return null; } else { try { string valor = sk.GetValue(KeyName.ToUpper()).ToString(); return valor.Replace("null", string.Empty); } catch { MessageBox.Show ("ERRO AO LER O REGISTRO"); return string.Empty; } } }
a chamada fica assim.
string valorChave = Read("NOME_DA_CHAVE");
se a resposta foi útil, classifique :)
ate mais,
Rodrigo Soria- Marcado como Resposta Levi Domingos quinta-feira, 9 de dezembro de 2010 16:08
Todas as Respostas
-
segue um exemplo que eu uso..
public string Read(string KeyName) { Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine; Microsoft.Win32.RegistryKey sk = rk.OpenSubKey("SOFTWARE\\NOME_DA_SUA_APLICACAO"); if (sk == null) { return null; } else { try { string valor = sk.GetValue(KeyName.ToUpper()).ToString(); return valor.Replace("null", string.Empty); } catch { MessageBox.Show ("ERRO AO LER O REGISTRO"); return string.Empty; } } }
a chamada fica assim.
string valorChave = Read("NOME_DA_CHAVE");
se a resposta foi útil, classifique :)
ate mais,
Rodrigo Soria -
segue um exemplo que eu uso..
public string Read(string KeyName) { Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine; Microsoft.Win32.RegistryKey sk = rk.OpenSubKey("SOFTWARE\\NOME_DA_SUA_APLICACAO"); if (sk == null) { return null; } else { try { string valor = sk.GetValue(KeyName.ToUpper()).ToString(); return valor.Replace("null", string.Empty); } catch { MessageBox.Show ("ERRO AO LER O REGISTRO"); return string.Empty; } } }
a chamada fica assim.
string valorChave = Read("NOME_DA_CHAVE");
se a resposta foi útil, classifique :)
ate mais,
Rodrigo Soria- Marcado como Resposta Levi Domingos quinta-feira, 9 de dezembro de 2010 16:08