111,126
社区成员
发帖
与我相关
我的任务
分享
MEMORYSTATUS ms = new MEMORYSTATUS();
NativeMethods.GlobalMemoryStatus(out ms);
MessageBox.Show((ms.dwTotalPhys/1024/1024).ToString());
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct MEMORYSTATUS
{
/// DWORD->unsigned int
public uint dwLength;
/// DWORD->unsigned int
public uint dwMemoryLoad;
/// SIZE_T->ULONG_PTR->unsigned int
public uint dwTotalPhys;
/// SIZE_T->ULONG_PTR->unsigned int
public uint dwAvailPhys;
/// SIZE_T->ULONG_PTR->unsigned int
public uint dwTotalPageFile;
/// SIZE_T->ULONG_PTR->unsigned int
public uint dwAvailPageFile;
/// SIZE_T->ULONG_PTR->unsigned int
public uint dwTotalVirtual;
/// SIZE_T->ULONG_PTR->unsigned int
public uint dwAvailVirtual;
}
public partial class NativeMethods
{
/// Return Type: void
///lpBuffer: LPMEMORYSTATUS->_MEMORYSTATUS*
[System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "GlobalMemoryStatus")]
public static extern void GlobalMemoryStatus([System.Runtime.InteropServices.OutAttribute()] out MEMORYSTATUS lpBuffer);
}