Ejemplo n.º 1
0
        public static void setVirtualMemory(UIComboBox disk, int size, ref UILabel display)
        {
            driveSetImpl = new DriveSetImpl();
            if (size < 0)
            {
                MessageBox.Show("输入错误!", "提示");
                return;
            }
            //if()
            if ((driveSetImpl._drives[disk.SelectedIndex].AvailableFreeSpace / 1024 / 1024 / 1024) + (driveSetImpl._drives[disk.SelectedIndex].AvailableFreeSpace / 1024 / 1024 / 1024) < size)
            {
                MessageBox.Show("虚拟内存不可大于磁盘剩余空间!", "提示");
                return;
            }
            List <string> list = new List <string>();

            for (int i = 0; i < driveSetImpl._drives.Count; i++)
            {
                if (i == disk.SelectedIndex)
                {
                    if (size != 0)
                    {
                        list.Add(DriveSetImpl.VirtualMemoryFormatString(driveSetImpl._drives[i].Name, size * 1024));
                    }
                }
                else
                {
                    if (driveSetImpl._drives[i].VirtualMemoryMaxSizeMb != 0)
                    {
                        list.Add(DriveSetImpl.VirtualMemoryFormatString(driveSetImpl._drives[i].Name, driveSetImpl._drives[i].VirtualMemoryMaxSizeMb));
                    }
                }
            }
            DriveSetImpl.SetValue(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "PagingFiles", list.ToArray());
            UIMessageBox.ShowSuccess("虚拟内存设置成功,重启后生效");
            driveSetImpl = new DriveSetImpl();
            display.Text = "本盘已使用虚拟内存" + (driveSetImpl._drives[disk.SelectedIndex].VirtualMemoryMaxSizeMb / 1024).ToString() + "GB," + "剩余空间" + (driveSetImpl._drives[disk.SelectedIndex].AvailableFreeSpace / 1024 / 1024 / 1024).ToString() + "GB";
        }
Ejemplo n.º 2
0
 public static void getVirtualMemoryUsage(int index, ref UILabel display)
 {
     driveSetImpl = new DriveSetImpl();
     display.Text = "本盘已使用虚拟内存" + (driveSetImpl._drives[index].VirtualMemoryMaxSizeMb / 1024).ToString() + "GB," + "剩余空间" + (driveSetImpl._drives[index].AvailableFreeSpace / 1024 / 1024 / 1024).ToString() + "GB";
 }