Exemple #1
0
        public void TestGetTotalMemory()
        {
#if !(NETCOREAPP2_0)
            var windowsSystemInfo = new WMISystemInfo();
            var wmiMem            = windowsSystemInfo.GetTotalMemoryMB();
            Console.WriteLine("WMI Total memory:  {0:F2} MB", wmiMem);
#endif
            // Use P/Invoke to access kernel32.dll
            var wpsi    = new WindowsSystemInfo();
            var pinvMem = wpsi.GetTotalMemoryMB();
            Console.WriteLine("PInv Total memory: {0:F2} MB", pinvMem);

#if !(NETCOREAPP2_0)
            Assert.AreEqual(wmiMem, pinvMem, 0.001);
#endif
        }