zoukankan      html  css  js  c++  java
  • Asp.net获取系统信息

            [DllImport("kernel32")]
            public static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo);


            [StructLayout(LayoutKind.Sequential)]
            public struct MEMORY_INFO
            {
                public uint dwLength;
                public uint dwMemoryLoad;
                public uint dwTotalPhys;
                public uint dwAvailPhys;
                public uint dwTotalPageFile;
                public uint dwAvailPageFile;
                public uint dwTotalVirtual;
                public uint dwAvailVirtual;
            }


            protected string MemberName, AdminLevel, MemoryLoad, TotalPhys, AvailPhys, TotalPageFile, AvailPageFile, TotalVirtual;
            protected string ServerOS, CpuSum, CpuType, MachineName, ServerName, ServerPath, ServerNet, ServerArea, ServerTimeOut, ServerStart, UsersTxt;
            protected string PrStart, AspNetN, AspNetCpu, ServerSessions, ServerApp, ServerCache, ServerAppN, ServerFso, RunTime, SessionTime, VersionTxt;
            protected string SiteTitle, SiteUrl;
           
            protected void Page_Load(object sender, EventArgs e)
            {

                this.CheckPower();

                if (this.adminer != null)
                {
                    DataLoad();
                }
            }


            private void DataLoad()
            {
                DateTime sTime = DateTime.Now;

                MemberName = "";

                ServerOS = Environment.OSVersion.ToString();
                CpuSum = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS");
                CpuType = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER");
                MachineName = Server.MachineName;
                ServerName = Request.ServerVariables["SERVER_NAME"];
                ServerPath = Request.ServerVariables["APPL_PHYSICAL_PATH"];
                ServerNet = ".NET CLR " + Environment.Version.ToString();
                ServerArea = (DateTime.Now - DateTime.UtcNow).TotalHours > 0 ? "+" + (DateTime.Now - DateTime.UtcNow).TotalHours.ToString() : (DateTime.Now - DateTime.UtcNow).TotalHours.ToString();
                ServerTimeOut = Server.ScriptTimeout.ToString();
                ServerStart = ((Double)System.Environment.TickCount / 3600000).ToString("N2");
                PrStart = GetPrStart();
                AspNetN = GetAspNetN();
                AspNetCpu = GetAspNetCpu();
                ServerSessions = Session.Contents.Count.ToString();
                ServerApp = Application.Contents.Count.ToString();
                ServerCache = Cache.Count.ToString();
                ServerAppN = GetServerAppN();
                ServerFso = Check("Scripting.FileSystemObject");
                ServerTimeOut = Server.ScriptTimeout.ToString() + "毫秒";

                SessionTime = HttpContext.Current.Session.Timeout.ToString();


                MEMORY_INFO MemInfo;
                MemInfo = new MEMORY_INFO();
                GlobalMemoryStatus(ref MemInfo);
                MemoryLoad = MemInfo.dwMemoryLoad + " %";
                TotalPhys = dFileSize(MemInfo.dwTotalPhys);
                AvailPhys = dFileSize(MemInfo.dwAvailPhys);
                TotalPageFile = dFileSize(MemInfo.dwTotalPageFile);
                AvailPageFile = dFileSize(MemInfo.dwAvailPageFile);
                TotalVirtual = dFileSize(MemInfo.dwTotalVirtual);

            }

  • 相关阅读:
    用C#做成的程序如何打包部署,在其他PC机运行
    ZeroMQ——一个轻量级的消息通信组件 C#
    Google Protocol Buffers 快速入门(带生成C#源码的方法)
    【转】如何一直保持测试工作的热情
    【转】关于什么是测试专家的讨论
    释放对某端口的占用
    Android端手机测试体系
    【转】减少缺陷漏测的系统方法体系思考(10年经验的反思)
    【转】3种类型的测试专家之路选择
    【转】手机应用软件测试点汇总
  • 原文地址:https://www.cnblogs.com/chengeng/p/3287009.html
Copyright © 2011-2022 走看看