On the screenshot is what I am dealing with basically I know don't know the second part of the name before my game launches because its generated randomly based on monitor ID or something.
Currently I use this and its simply not possible to do it this way I think.
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\AAA\MyApp\test\", false);
if (key != null)
{
return (string)key.GetValue("Screenmanager Resolution ....");
}
else
{
return null;
}
I would then like to set the value myself like
key.SetValue("Screenmanager Resolution Width_h182942802", 1024, RegistryValueKind.DWord);
You can get the value names with GetValueNames()
and then see if the "Screen Resolution *" value exists:
string[] valueNames = key.GetValueNames();
string valueName = valueNames.FirstOrDefault(s => s.StartsWith("Screenmanager Resolution Width_"));
if(valueName != null)
{
return key.GetValue(valueName);
}
or without LINQ:
foreach(string valueName in key.GetValueNames())
{
if(valueName.StartsWith("Screenmanager Resolution Width_"))
return key.GetValue(valueName);
}
return null;