G
Guest
Hi!
I am using the following piece of code to get registry data from the device:
string keyName = "ControlPanel\\Owner";
string valueName = "PowrPass";
int powrPass = 0;
RegistryKey passwordRegKey = Registry.CurrentUser.OpenSubKey(keyName);
if (passwordRegKey.ValueCount == 0)
{
MessageBox.Show("Unknown");
}
else
{
powrPass = (int) passwordRegKey.GetValue(valueName); //Exception raised
here
MessageBox.Show(powrPass.ToString());
}
passwordRegKey.Close();
When I run the app, I get an InvalidCastException. How can I resolve this
issue?
Thanks for your time.
Regards,
Kumar
I am using the following piece of code to get registry data from the device:
string keyName = "ControlPanel\\Owner";
string valueName = "PowrPass";
int powrPass = 0;
RegistryKey passwordRegKey = Registry.CurrentUser.OpenSubKey(keyName);
if (passwordRegKey.ValueCount == 0)
{
MessageBox.Show("Unknown");
}
else
{
powrPass = (int) passwordRegKey.GetValue(valueName); //Exception raised
here
MessageBox.Show(powrPass.ToString());
}
passwordRegKey.Close();
When I run the app, I get an InvalidCastException. How can I resolve this
issue?
Thanks for your time.
Regards,
Kumar