| 1 | /* |
|---|
| 2 | * $Id$ |
|---|
| 3 | * Copyright 2008-2010 The Eraser Project |
|---|
| 4 | * Original Author: Joel Low <lowjoel@users.sourceforge.net> |
|---|
| 5 | * Modified By: |
|---|
| 6 | * |
|---|
| 7 | * This file is part of Eraser. |
|---|
| 8 | * |
|---|
| 9 | * Eraser is free software: you can redistribute it and/or modify it under the |
|---|
| 10 | * terms of the GNU General Public License as published by the Free Software |
|---|
| 11 | * Foundation, either version 3 of the License, or (at your option) any later |
|---|
| 12 | * version. |
|---|
| 13 | * |
|---|
| 14 | * Eraser is distributed in the hope that it will be useful, but WITHOUT ANY |
|---|
| 15 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
|---|
| 16 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|---|
| 17 | * |
|---|
| 18 | * A copy of the GNU General Public License can be found at |
|---|
| 19 | * <http://www.gnu.org/licenses/>. |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | using System; |
|---|
| 23 | using System.Collections.Generic; |
|---|
| 24 | using System.Text; |
|---|
| 25 | using Microsoft.Win32; |
|---|
| 26 | |
|---|
| 27 | namespace Eraser.Util |
|---|
| 28 | { |
|---|
| 29 | public static class Shell |
|---|
| 30 | { |
|---|
| 31 | /// <summary> |
|---|
| 32 | /// Gets or sets whether low disk space notifications are enabled for the |
|---|
| 33 | /// current user. |
|---|
| 34 | /// </summary> |
|---|
| 35 | public static bool LowDiskSpaceNotificationsEnabled |
|---|
| 36 | { |
|---|
| 37 | get |
|---|
| 38 | { |
|---|
| 39 | using (RegistryKey key = Registry.CurrentUser.OpenSubKey( |
|---|
| 40 | "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer")) |
|---|
| 41 | { |
|---|
| 42 | if (key == null) |
|---|
| 43 | return true; |
|---|
| 44 | return !Convert.ToBoolean(key.GetValue("NoLowDiskSpaceChecks", false)); |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | set |
|---|
| 48 | { |
|---|
| 49 | RegistryKey key = null; |
|---|
| 50 | try |
|---|
| 51 | { |
|---|
| 52 | key = Registry.CurrentUser.OpenSubKey( |
|---|
| 53 | "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", true); |
|---|
| 54 | if (key == null) |
|---|
| 55 | key = Registry.CurrentUser.CreateSubKey( |
|---|
| 56 | "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"); |
|---|
| 57 | key.SetValue("NoLowDiskSpaceChecks", !value); |
|---|
| 58 | } |
|---|
| 59 | finally |
|---|
| 60 | { |
|---|
| 61 | if (key != null) |
|---|
| 62 | key.Close(); |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | } |
|---|