Monday, June 14, 2021

【Visual Studio Visual Csharp】Total Physical Memory

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace totalPhysicalMemoryC { public partial class Form1 : Form { public Form1() { InitializeComponent(); } static ulong GetTotalPhysicalMemory() { return new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory; } static long ConvertBytesToMegabytes(long bytes) { return (bytes / 1024) / 1024; } private void button1_Click(object sender, EventArgs e) { MessageBox.Show(ConvertBytesToMegabytes((long)GetTotalPhysicalMemory()).ToString() + " MB"); } } }

No comments:

Post a Comment