Abstractions.Windows.User.SetQuota C# (CSharp) Метод

SetQuota() публичный статический Метод

sets user profile quota
public static SetQuota ( Abstractions where, string name, uint quota ) : System.Boolean
where Abstractions ROOTKEY hklm or hku
name string SubKey name
quota uint if 0 means the profile quota GPO it will be deleted
Результат System.Boolean
        public static Boolean SetQuota(Abstractions.WindowsApi.pInvokes.structenums.RegistryLocation where, string name, uint quota)
        {
            LibraryLogging.Info("set Quota for {0}", name);
            try
            {
                using (RegistryKey key = Abstractions.WindowsApi.pInvokes.GetRegistryLocation(where).CreateSubKey(name + @"\Software\Microsoft\Windows\CurrentVersion\Policies\System"))
                {
                    if (quota > 0)
                    {
                        key.SetValue("EnableProfileQuota", 1, RegistryValueKind.DWord);
                        //key.SetValue("ProfileQuotaMessage", "You have exceeded your profile storage space. Before you can log off, you need to move some items from your profile to network or local storage.", RegistryValueKind.String);
                        key.SetValue("MaxProfileSize", quota, RegistryValueKind.DWord);
                        key.SetValue("IncludeRegInProQuota", 1, RegistryValueKind.DWord);
                        key.SetValue("WarnUser", 1, RegistryValueKind.DWord);
                        key.SetValue("WarnUserTimeout", 5, RegistryValueKind.DWord);
                    }
                    else
                    {
                        key.DeleteValue("EnableProfileQuota", false);
                        key.DeleteValue("ProfileQuotaMessage", false);
                        key.DeleteValue("MaxProfileSize", false);
                        key.DeleteValue("IncludeRegInProQuota", false);
                        key.DeleteValue("WarnUser", false);
                        key.DeleteValue("WarnUserTimeout", false);
                    }
                }
            }
            catch (Exception ex)
            {
                LibraryLogging.Error("Can't set profile quota for {0} Error:{1}", name, ex.Message);
                return false;
            }

            return true;
        }