1010using Microsoft . Win32 . SafeHandles ;
1111
1212namespace winMemoryOptimizer {
13-
13+
1414 internal class ComputerService {
1515
16- public static bool HasCombinedPageList => OperatingSystemHelper . IsWindows8OrGreater ;
17- public static bool HasModifiedPageList => OperatingSystemHelper . IsWindowsVistaOrGreater ;
18- public static bool HasProcessesWorkingSet => OperatingSystemHelper . IsWindowsXpOrGreater ;
19- public static bool HasStandbyList => OperatingSystemHelper . IsWindowsVistaOrGreater ;
20- public static bool HasSystemWorkingSet => OperatingSystemHelper . IsWindowsXpOrGreater ;
21- public static bool HasModifiedFileCache => OperatingSystemHelper . IsWindowsXpOrGreater ;
22- public static bool HasSystemFileCache => OperatingSystemHelper . IsWindowsXpOrGreater ;
23- public static bool HasRegistryCache => OperatingSystemHelper . IsWindows81OrGreater ;
16+ public static bool HasCombinedPageList => OSHelper . IsWindows8OrGreater ;
17+ public static bool HasModifiedPageList => OSHelper . IsWindowsVistaOrGreater ;
18+ public static bool HasProcessesWorkingSet => OSHelper . IsWindowsXpOrGreater ;
19+ public static bool HasStandbyList => OSHelper . IsWindowsVistaOrGreater ;
20+ public static bool HasSystemWorkingSet => OSHelper . IsWindowsXpOrGreater ;
21+ public static bool HasModifiedFileCache => OSHelper . IsWindowsXpOrGreater ;
22+ public static bool HasSystemFileCache => OSHelper . IsWindowsXpOrGreater ;
23+ public static bool HasRegistryCache => OSHelper . IsWindows81OrGreater ;
2424
2525 private WindowsStructs . MemoryStatusEx memoryStatusEx ;
2626
@@ -45,7 +45,7 @@ public bool UpdateMemoryState() {
4545 }
4646 return false ;
4747 }
48-
48+
4949 public event Action < byte , string > OnOptimizeProgressUpdate ;
5050
5151 private static bool SetIncreasePrivilege ( string privilegeName ) {
@@ -199,11 +199,11 @@ public void Optimize(Enums.MemoryAreas areas, Enums.OptimizationReason reason) {
199199 value ++ ;
200200 OnOptimizeProgressUpdate ( value , "Modified File Cache" ) ;
201201 }
202-
202+
203203 stopwatch . Restart ( ) ;
204-
204+
205205 OptimizeModifiedFileCache ( ) ;
206-
206+
207207 runtime = runtime . Add ( stopwatch . Elapsed ) ;
208208
209209 infoLog . AppendLine ( string . Format ( infoLogFormat , "Modified file cache" , "Optimized" ,
@@ -329,7 +329,7 @@ private static void OptimizeModifiedFileCache() {
329329 if ( handle == null || handle . IsInvalid )
330330 continue ;
331331
332- if ( OperatingSystemHelper . IsWindows7OrGreater ) {
332+ if ( OSHelper . IsWindows7OrGreater ) {
333333 try {
334334 var buffer = Marshal . AllocHGlobal ( 1 ) ;
335335 try {
@@ -345,9 +345,9 @@ private static void OptimizeModifiedFileCache() {
345345 // ignored
346346 }
347347
348- if ( OperatingSystemHelper . IsWindows8OrGreater ) {
348+ if ( OSHelper . IsWindows8OrGreater ) {
349349 try {
350- if ( ! NativeMethods . DeviceIoControl ( handle , Constants . Windows . Drive . FsctlDiscardVolumeCache ,
350+ if ( ! NativeMethods . DeviceIoControl ( handle , Constants . Windows . Drive . FsctlDiscardVolumeCache ,
351351 IntPtr . Zero , 0 , IntPtr . Zero , 0 , out _ , IntPtr . Zero ) )
352352 throw new Win32Exception ( Marshal . GetLastWin32Error ( ) ) ;
353353 }
@@ -462,7 +462,7 @@ private static void OptimizeSystemWorkingSet() {
462462 var handle = GCHandle . Alloc ( 0 ) ;
463463 try {
464464 object systemCacheInformation ;
465- if ( OperatingSystemHelper . Is64Bit )
465+ if ( OSHelper . Is64Bit )
466466 systemCacheInformation = new WindowsStructs . SystemCacheInformation64
467467 { MinimumWorkingSet = - 1L , MaximumWorkingSet = - 1L } ;
468468 else
@@ -501,7 +501,7 @@ private static void OptimizeSystemFileCache() {
501501 try {
502502 object systemFileCacheInformation ;
503503
504- if ( OperatingSystemHelper . Is64Bit )
504+ if ( OSHelper . Is64Bit )
505505 systemFileCacheInformation = new WindowsStructs . SystemFileCacheInformation64
506506 { MinimumWorkingSet = - 1L , MaximumWorkingSet = - 1L } ;
507507 else
@@ -552,4 +552,4 @@ private static SafeFileHandle OpenVolumeHandle(string driveLetter) {
552552 ) ;
553553 }
554554 }
555- }
555+ }
0 commit comments