private static void Win32ErrorStatic(int errorCode, string str)
{
switch (errorCode)
{
case Interop.Errors.ERROR_ACCESS_DENIED:
throw str != null ?
new UnauthorizedAccessException(SR.Format(SR.UnauthorizedAccess_RegistryKeyGeneric_Key, str)) :
new UnauthorizedAccessException();
default:
throw new IOException(Interop.Kernel32.GetMessage(errorCode), errorCode);
}
}