@msdn=http://msdn.microsoft.com/en-us/library/windows/desktop/aa965240%28v=vs.85%29.aspx @pinvoke=http://pinvoke.net/$$$.htm Summary: Limits the size of the working set for the file system cache. !!!!C# Signature: /// <summary>Limits the size of the working set for the file system cache.</summary> /// <param name="MinimumFileCacheSize">The minimum size of the file cache, in bytes. To flush, use UInt64.MaxValue.</param> /// <param name="MaximumFileCacheSize">The maximum size of the file cache, in bytes. Must be > min + 64KB</param> /// <param name="Flags">See File_Cache_Flags</param> /// <returns>0=fail !0=success</returns> [DllImport("kernel32.dll", SetLastError=true)] static extern Int32 SetSystemFileCacheSize(IntPtr MinimumFileCacheSize, IntPtr MaximumFileCacheSize, File_Cache_Flags Flags); !!!!VB Signature: Declare Function SetSystemFileCacheSize Lib "kernel32.dll" (TODO) As TODO !!!!User-Defined Types: /// <summary>Flags for use with SetSystemFileCacheSize. Note that corresponding enable & disable are mutually exclusive and will fail.</summary> [Flags] public enum File_Cache_Flags : uint { MAX_HARD_ENABLE = 0x00000001, MAX_HARD_DISABLE = 0x00000002, MIN_HARD_ENABLE = 0x00000004, MIN_HARD_DISABLE = 0x00000008, } !!!!Notes: None. !!!!Tips & Tricks: Please add some! !!!!Sample Code: /// <summary>Sets or unsets File Cache Size</summary> /// <param name="MinimumFileCacheSize">Minimum Size, or zero for disable minimum</param> /// <param name="MaximumFileCacheSize">Maximum Size, or zero for disable maximum</param> public static void SetSystemFileCacheSize(ulong MinimumFileCacheSize, ulong MaximumFileCacheSize) { if (Environment.OSVersion.Version.Major < 5 || (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor < 2)) throw new NotImplementedException("Windows 5.2 (XP 64/2003 and up) is required for File System Cache Control"); if (IntPtr.Size == 4 && MinimumFileCacheSize > UInt32.MaxValue) throw new InvalidOperationException("Minimum Size is Invalid - SetSystemFileCacheSize"); if (IntPtr.Size == 4 && MaximumFileCacheSize > UInt32.MaxValue) MaximumFileCacheSize = UInt32.MaxValue; File_Cache_Flags flags = (File_Cache_Flags)0; if (MinimumFileCacheSize > 0) flags |= File_Cache_Flags.MIN_HARD_ENABLE; else flags |= File_Cache_Flags.MIN_HARD_DISABLE; if (MaximumFileCacheSize > 0 && MaximumFileCacheSize>MinimumFileCacheSize + 64 * 1024) // min must be <64K lower flags |= File_Cache_Flags.MAX_HARD_ENABLE; else flags |= File_Cache_Flags.MAX_HARD_DISABLE; int result = 0; if(IntPtr.Size!=4) result = SetSystemFileCacheSize(new IntPtr((long)MinimumFileCacheSize), new IntPtr((long)MaximumFileCacheSize), flags); else result = SetSystemFileCacheSize(new IntPtr((int)MinimumFileCacheSize), new IntPtr((int)MaximumFileCacheSize), flags); if (result == 0) throw new Win32Exception(); } Documentation: SetSystemFileCacheSize@msdn on MSDN
Edit kernel32.SetSyste...
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.