private uint PSBufferGetSpace() { // Assume that we have 1 GB of available space. uint space = 1024 * 1024 * 1024; NativeStructs.MEMORYSTATUSEX buffer = new NativeStructs.MEMORYSTATUSEX() { dwLength = (uint)Marshal.SizeOf(typeof(NativeStructs.MEMORYSTATUSEX)) }; if (SafeNativeMethods.GlobalMemoryStatusEx(ref buffer)) { if (buffer.ullAvailVirtual < uint.MaxValue) { space = (uint)buffer.ullAvailVirtual; } } return(space); }
private int BufferSpaceProc() { // Assume that we have 1 GB of available space. int space = 1024 * 1024 * 1024; NativeStructs.MEMORYSTATUSEX buffer = new NativeStructs.MEMORYSTATUSEX { dwLength = (uint)Marshal.SizeOf(typeof(NativeStructs.MEMORYSTATUSEX)) }; if (SafeNativeMethods.GlobalMemoryStatusEx(ref buffer)) { if (buffer.ullAvailVirtual < (ulong)space) { space = (int)buffer.ullAvailVirtual; } } return(space); }