private static int ReadInteger(RegistryKey key, string name, int defaultValue) { var val = key?.GetValue(name); if (val is int) { return (int) val; } return defaultValue; }