| 1 |
using System;
|
| 2 |
using System.Collections.Generic;
|
| 3 |
using System.Linq;
|
| 4 |
using System.Text;
|
| 5 |
using System.Text.RegularExpressions;
|
| 6 |
using Microsoft.Win32;
|
| 7 |
using Winfoot_7_SDK;
|
| 8 |
|
| 9 |
namespace WinfootDefaultPerformancePlugin.Controls.Strategy
|
| 10 |
{
|
| 11 |
public interface ISchedulerThreadPriorityStrategy
|
| 12 |
{
|
| 13 |
void Write(int num);
|
| 14 |
WFRegistry Read();
|
| 15 |
List<WFRegistry> BackUp();
|
| 16 |
}
|
| 17 |
|
| 18 |
public class SchedulerThreadPriorityDefaultStrategy : ICorrespondenceOS, ISchedulerThreadPriorityStrategy
|
| 19 |
{
|
| 20 |
public SchedulerThreadPriorityDefaultStrategy()
|
| 21 |
{
|
| 22 |
CorrespondenceOSList = new List<OS>
|
| 23 |
{
|
| 24 |
OS.WindowsXP,
|
| 25 |
OS.WindoesXP_SP1,
|
| 26 |
OS.WindowsXP_SP2,
|
| 27 |
OS.WindowsXP_SP3,
|
| 28 |
OS.WindowsVista,
|
| 29 |
OS.WindowsVista_SP1,
|
| 30 |
|
| 31 |
#if DEBUG
|
| 32 |
OS.WindowsSeven
|
| 33 |
#endif
|
| 34 |
};
|
| 35 |
}
|
| 36 |
|
| 37 |
private string RegName = "SchedulerThreadPriority";
|
| 38 |
|
| 39 |
#region ICorrespondenceOS メンバ
|
| 40 |
|
| 41 |
public List<OS> CorrespondenceOSList { get; set; }
|
| 42 |
|
| 43 |
#endregion
|
| 44 |
|
| 45 |
public void Write(int num)
|
| 46 |
{
|
| 47 |
RegistryKey registryKey =
|
| 48 |
Registry.LocalMachine.CreateSubKey(
|
| 49 |
@"SYSTEM\CurrentControlSet\Control\Print");
|
| 50 |
|
| 51 |
registryKey.SetValue(RegName,num,RegistryValueKind.DWord);
|
| 52 |
}
|
| 53 |
|
| 54 |
public WFRegistry Read()
|
| 55 |
{
|
| 56 |
RegistryKey registryKey =
|
| 57 |
Registry.LocalMachine.OpenSubKey(
|
| 58 |
@"SYSTEM\CurrentControlSet\Control\Print");
|
| 59 |
|
| 60 |
return new WFRegistry(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print", RegName,
|
| 61 |
registryKey.GetValue(RegName, 0), RegistryValueKind.DWord, RegOperation.ValueWrite);
|
| 62 |
}
|
| 63 |
|
| 64 |
public List<WFRegistry> BackUp()
|
| 65 |
{
|
| 66 |
return new List<WFRegistry> { Read() };
|
| 67 |
}
|
| 68 |
|
| 69 |
}
|
| 70 |
|
| 71 |
public class SchedulerThreadPriorityController
|
| 72 |
{
|
| 73 |
public SchedulerThreadPriorityController(SchedulerThreadPriority schedulerThreadPriority,
|
| 74 |
ISchedulerThreadPriorityStrategy strategy)
|
| 75 |
{
|
| 76 |
SchedulerThreadPriority = schedulerThreadPriority;
|
| 77 |
Strategy = strategy;
|
| 78 |
}
|
| 79 |
|
| 80 |
public SchedulerThreadPriority SchedulerThreadPriority { get; set; }
|
| 81 |
public ISchedulerThreadPriorityStrategy Strategy { get; set; }
|
| 82 |
|
| 83 |
public void Read()
|
| 84 |
{
|
| 85 |
SchedulerThreadPriority.SetScheschedulerThreadPriorityValue(Convert.ToInt32(Strategy.Read().Value));
|
| 86 |
}
|
| 87 |
|
| 88 |
public void Write()
|
| 89 |
{
|
| 90 |
Strategy.Write(SchedulerThreadPriority.GetScheschedulerThreadPriorityValue());
|
| 91 |
}
|
| 92 |
|
| 93 |
public List<WFRegistry> BackUp()
|
| 94 |
{
|
| 95 |
return Strategy.BackUp();
|
| 96 |
}
|
| 97 |
}
|
| 98 |
}
|