How to check if a registry value exists by C# code? This is my code, I want to check if \'Start\' exists.
public static bool checkMachineType()
{
Registr
public bool ValueExists(RegistryKey Key, string Value)
{
try
{
return Key.GetValue(Value) != null;
}
catch
{
return false;
}
}
This simple function will return true only if a value is found but it is not null, else will return false if the value exists but it is null or the value doesn't exists in the key.
USAGE for your question:
if (ValueExists(winLogonKey, "Start")
{
// The values exists
}
else
{
// The values does not exists
}