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);

            }

  • 相关阅读:
    ASP.NET Web API 框架研究 Self Host模式下的消息处理管道
    ASP.NET Web API 框架研究 Web Host模式下的消息处理管道
    ASP.NET Web API 框架研究 核心的消息处理管道
    ASP.NET Web API 框架研究 Web Host模式路由及将请求转出到消息处理管道
    ASP.NET Web API 框架研究 ASP.NET Web API 路由
    ASP.NET Web API 框架研究 ASP.NET 路由
    ASP.NET Web API 入门 (API接口、寄宿方式、HttpClient调用)
    MVVM模式
    RESTful Web API 理解
    C# 函数式编程及Monads.net库
  • 原文地址:https://www.cnblogs.com/chengeng/p/3287009.html
Copyright © 2011-2022 走看看