private void DeleteValueCore(string name, bool throwOnMissingValue)
{
int errorCode = Interop.Advapi32.RegDeleteValue(_hkey, name);
//
// From windows 2003 server, if the name is too long we will get error code ERROR_FILENAME_EXCED_RANGE
// This still means the name doesn't exist. We need to be consistent with previous OS.
//
if (errorCode == Interop.Errors.ERROR_FILE_NOT_FOUND ||
errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE)
{
if (throwOnMissingValue)
{
ThrowHelper.ThrowArgumentException(SR.Arg_RegSubKeyValueAbsent);
}
else
{
// Otherwise, reset and just return giving no indication to the user.
// (For compatibility)
errorCode = 0;
}
}
// We really should throw an exception here if errorCode was bad,
// but we can't for compatibility reasons.
Debug.Assert(errorCode == 0, "RegDeleteValue failed. Here's your error code: " + errorCode);
}