Registry
-
I have a string value in the registry that i'm trying to read into my app. I need this value to be read as an integer so i can use it in a custom function.
RegistryKey rk = Registry.Users; rk = rk.OpenSubKey(@".DEFAULT\CustomForm", false); int result = calculate(rk.GetValue("GRN1"),2); public int calculate(int x, int y) { int result = x * y; return result; }
Therk.GetValue("GRN1")
returns an Object Type, but how can i get it to return an Integer type. I get an 'Invalid Cast' error when i try to cast from a different 'domain' (as msdn calls it)....int result = calculate((int)rk.GetValue("GRN1"),2);
so, how can i get an object value from the registry to convert to an integer? Thanks for your help .gonad. -
I have a string value in the registry that i'm trying to read into my app. I need this value to be read as an integer so i can use it in a custom function.
RegistryKey rk = Registry.Users; rk = rk.OpenSubKey(@".DEFAULT\CustomForm", false); int result = calculate(rk.GetValue("GRN1"),2); public int calculate(int x, int y) { int result = x * y; return result; }
Therk.GetValue("GRN1")
returns an Object Type, but how can i get it to return an Integer type. I get an 'Invalid Cast' error when i try to cast from a different 'domain' (as msdn calls it)....int result = calculate((int)rk.GetValue("GRN1"),2);
so, how can i get an object value from the registry to convert to an integer? Thanks for your help .gonad. -
I have a string value in the registry that i'm trying to read into my app. I need this value to be read as an integer so i can use it in a custom function.
RegistryKey rk = Registry.Users; rk = rk.OpenSubKey(@".DEFAULT\CustomForm", false); int result = calculate(rk.GetValue("GRN1"),2); public int calculate(int x, int y) { int result = x * y; return result; }
Therk.GetValue("GRN1")
returns an Object Type, but how can i get it to return an Integer type. I get an 'Invalid Cast' error when i try to cast from a different 'domain' (as msdn calls it)....int result = calculate((int)rk.GetValue("GRN1"),2);
so, how can i get an object value from the registry to convert to an integer? Thanks for your help .gonad.Convert.ToInt32(rk.GetValue("GRN1")) should do the trick.