B
Bry
I'm having problems writing (and reading) boolean data to the registry.
// Write a boolean value to the registry
// I've not included the obvious bits of code in these samples
bool myBool = true;
myRegistryKey.SetValue("SomeValue", myBool);
This gives me a registry value with string data containing "True"
// Read my boolean data back from the registry
bool myBool;
myRegistryKey.GetValue("SomeValue");
This produces a run time error, "InvalidCastException" was unhandled
I understand why I'm getting the exception, but I'm not sure what I
need to do to achieve what I'm trying to do. Can anyone point out what
I'm missing?
Thanks.
// Write a boolean value to the registry
// I've not included the obvious bits of code in these samples
bool myBool = true;
myRegistryKey.SetValue("SomeValue", myBool);
This gives me a registry value with string data containing "True"
// Read my boolean data back from the registry
bool myBool;
myRegistryKey.GetValue("SomeValue");
This produces a run time error, "InvalidCastException" was unhandled
I understand why I'm getting the exception, but I'm not sure what I
need to do to achieve what I'm trying to do. Can anyone point out what
I'm missing?
Thanks.