Exemple #1
0
        /// <summary>
        /// 设置进程的程序集大小,将部分物理内存占用转移到虚拟内存
        /// </summary>
        /// <param name="pid">要设置的进程ID</param>
        /// <param name="min">最小值</param>
        /// <param name="max">最大值</param>
        /// <returns></returns>
        public static bool SetProcessWorkingSetSize(int pid, int min, int max)
        {
            var p = pid <= 0 ? Process.GetCurrentProcess() : Process.GetProcessById(pid);

            return(Win32Native.SetProcessWorkingSetSize(p.Handle, min, max));
        }
Exemple #2
0
        static string GetNTName(Version vs)
        {
            if (Mono)
            {
                return(null);
            }
            var ver = new Win32Native.OSVersionInfoEx();

            if (!Win32Native.GetVersionEx(ver))
            {
                ver = null;
            }
            var       isStation   = ver == null || ver.ProductType == OSProductType.WorkStation;
            var       is64        = Is64BitOperatingSystem;
            const int SM_SERVERR2 = 89;
            var       IsServerR2  = Win32Native.GetSystemMetrics(SM_SERVERR2) == 1;
            var       sys         = "";

            switch (vs.Major)
            {
            case 3:
                sys = "NT 3.51";
                break;

            case 4:
                sys = "NT 4.0";
                break;

            case 5:
                if (vs.Minor == 0)
                {
                    sys = "2000";
                    if (ver != null && ver.ProductType != OSProductType.WorkStation)
                    {
                        if (ver.SuiteMask == OSSuites.Enterprise)
                        {
                            sys += " Datacenter Server";
                        }
                        else if (ver.SuiteMask == OSSuites.Datacenter)
                        {
                            sys += " Advanced Server";
                        }
                        else
                        {
                            sys += " Server";
                        }
                    }
                }
                else if (vs.Minor == 1)
                {
                    sys = "XP";
                    if (ver != null)
                    {
                        if (ver.SuiteMask == OSSuites.EmbeddedNT)
                        {
                            sys += " Embedded";
                        }
                        else if (ver.SuiteMask == OSSuites.Personal)
                        {
                            sys += " Home";
                        }
                        else
                        {
                            sys += " Professional";
                        }
                    }
                }
                else if (vs.Minor == 2)
                {
                    // 64位XP也是5.2
                    if (is64 && ver != null && ver.ProductType == OSProductType.WorkStation)
                    {
                        sys = "XP Professional";
                    }
                    else if (ver != null && ver.SuiteMask == OSSuites.WHServer)
                    {
                        sys = "Home Server";
                    }
                    else
                    {
                        sys = "Server 2003";
                        if (IsServerR2)
                        {
                            sys += " R2";
                        }
                        if (ver != null)
                        {
                            switch (ver.SuiteMask)
                            {
                            case OSSuites.Enterprise:
                                sys += " Enterprise";
                                break;

                            case OSSuites.Datacenter:
                                sys += " Datacenter";
                                break;

                            case OSSuites.Blade:
                                sys += " Web";
                                break;

                            default:
                                sys += " Standard";
                                break;
                            }
                        }
                    }
                }
                else
                {
                    sys = string.Format("{0}.{1}", vs.Major, vs.Minor);
                }
                break;

            case 6:
                if (vs.Minor == 0)
                {
                    sys = isStation ? "Vista" : "Server 2008";
                }
                else if (vs.Minor == 1)
                {
                    sys = isStation ? "7" : "Server 2008 R2";
                }
                else if (vs.Minor == 2)
                {
                    if (vs.Build == 9200)
                    {
                        sys = "10.0";
                    }
                    else
                    {
                        sys = isStation ? "8" : "Server 2012";
                    }
                }
                else if (vs.Minor == 3)
                {
                    sys = isStation ? "8.1" : "Server 2012 R2";
                }
                else
                {
                    sys = string.Format("{0}.{1}", vs.Major, vs.Minor);
                }
                break;

            case 10:
                //sys = "10.0";
                sys = vs.ToString();
                break;

            default:
                sys = "NT " + vs.ToString();
                break;
            }
            return(sys);
        }