Server Environment Information "C # code get"

Source: Internet
Author: User
Tags servervariables

Server Environment Information "C # code get"
 Public classservicesmessage {[DllImport ("Kernel32", CharSet = CharSet.Auto, SetLastError =true)]Internal Static extern void GetSystemDirectory(StringBuilder Sysdir,intcount); [DllImport ("Kernel32", CharSet = CharSet.Auto, SetLastError =true)]Internal Static extern void GetSystemInfo(refCpu_info cpuinfo); [DllImport ("Kernel32", CharSet = CharSet.Auto, SetLastError =true)]Internal Static extern void GlobalMemoryStatus(refMemory_info meminfo); Public Static void Getsitemsgmodel()        {intMinor//server.machinename;//Server computer name            //request.servervariables["local_addr"];//server IP address            //request.servervariables["SERVER_NAME"];//Server domain name            //request.servervariables["Server_port"];//Server port            //request.servervariables["server_software"];//Server IIS version            //request.physicalpath;//Execute file absolute path            //request.physicalapplicationpath;//Site Virtual directory absolute path            //request.applicationpath;//serverapppath            //server operating system            # Region server operating system            //string fwqczxt = "";            //switch (Environment.OSVersion.Platform)            //    {            //Case PLATFORMID.WIN32S:            //FWQCZXT = "Win32s";            //break;            //Case platformid.win32windows:            //minor = Environment.OSVersion.Version.Minor;            //switch (minor)            //            {            //Case 0:            //FWQCZXT = "Microsoft Windows";            //break;            //Case:            //FWQCZXT = (Environment.OSVersion.Version.Revision.ToString () = = "2222A")? "Microsoft Windows 98 Second Edition": "Windows 98";            //break;            //Case:            //FWQCZXT = "Microsoft Windows Me";            //break;            //            }            //break;            //Case PLATFORMID.WIN32NT:            //switch (Environment.OSVersion.Version.Major)            //            {            //Case 3:            //FWQCZXT = "Microsoft Windows NT 3.51";            //break;            //Case 4:            //FWQCZXT = "Microsoft Windows NT 4.0";            //break;            //Case 5:            //switch (Environment.OSVersion.Version.Minor)            //                    {            //Case 0:            //FWQCZXT = "Microsoft Windows +";            //break;            //Case 1:            //FWQCZXT = "Microsoft Windows XP";            //break;            //Case 2:            //FWQCZXT = "Microsoft Windows 2003";            //break;            //                    }            //break;            //            }            //FWQCZXT = "Microsoft Windows NT";            //break;            //Case platformid.wince:            //FWQCZXT = "Microsoft Windows CE";            //break;            //    }             #endregion             //environment.expandenvironmentvariables ("%SystemRoot%");//server operating system installation directory            //environment.expandenvironmentvariables ("%ProgramFiles%");//server Application installation directory            //cultureinfo.installeduiculture.englishname;//.net Framework Language types            //.net Framework Version            //object[] Objarray = new object[] {Environment.Version.Major, ".", Environment.Version.Minor, ".", Environment.Version.Build, ".", Environment.Version.Revision};            //string. Concat (Objarray);            //datetime.now.tostring ();//server Current time            //The server was last started and is now running            # //server was last booted to now run            //timespan span = new TimeSpan (Environment.tickcount * 0x2710);            //string[] Strarray = new String[8];            //minor = (int) span. Totaldays;            //strarray[0] = minor. ToString ();            //strarray[1] = "Day";            //strarray[2] = span. Hours.tostring ();            //strarray[3] = "Hour";            //strarray[4] = span. Minutes.tostring ();            //strarray[5] = "min";            //strarray[6] = span. Seconds.tostring ();            //strarray[7] = "Second";            //string. Concat (Strarray);//server Last boot to now run            #endregion             //string. Join (",", Directory.getlogicaldrives ()). Replace (Path.directoryseparatorchar, ");//Logical driveMemory_info Meminfo =NewMemory_info ();//globalmemorystatus (ref meminfo);            //minor = (int) (meminfo.dwtotalphys/0x100000);            //minor. ToString ();//Total Physical memory MB            //minor = (int) (meminfo.dwavailphys/0x100000);            //minor. ToString ();//Available Physical memory MB            //meminfo.dwmemoryload.tostring ();//memory in use%            //minor = (int) (meminfo.dwtotalpagefile/0x100000);            //minor. ToString ();//swap file size MB            //minor = (int) (meminfo.dwavailpagefile/0x100000);            //minor. ToString ();//swap file available size MB            //minor = (int) (meminfo.dwtotalvirtual/0x100000);            //minor. ToString ();//total virtual memory MB            //((int) (meminfo.dwavailvirtual/0x100000)). ToString ();//remaining virtual memory MBCpu_info Cpuinfo =NewCpu_info ();//getsysteminfo (ref cpuinfo);            //cpuinfo.dwnumberofprocessors.tostring ();//CPU number            //environment.expandenvironmentvariables ("%processor_identifier%");//cpu identification            //cpuinfo.dwprocessortype.tostring ();//CPU type            //cpuinfo.dwprocessorlevel.tostring ();//CPU rating            //cpuinfo.dwoemid.tostring ();//cpu OEM ID            //cpuinfo.dwpagesize.tostring ();//cpu page Size}//Nested Types[StructLayout (LayoutKind.Sequential)] Public structCpu_info { Public UINTDwoemid; Public UINTdwPageSize; Public UINTlpminimumapplicationaddress; Public UINTlpmaximumapplicationaddress; Public UINTDwactiveprocessormask; Public UINTDwnumberofprocessors; Public UINTdwProcessorType; Public UINTdwallocationgranularity; Public UINTDwprocessorlevel; Public UINTDwprocessorrevision; } [StructLayout (LayoutKind.Sequential)] Public structMemory_info { Public UINTDwlength; Public UINTdwMemoryLoad; Public UINTdwTotalPhys; Public UINTdwAvailPhys; Public UINTdwTotalPageFile; Public UINTdwAvailPageFile; Public UINTdwtotalvirtual; Public UINTdwAvailVirtual; }    }

The request in the code above is requested in the context of requests.
Time is relatively tight, not tidy more clearly.

The final effect is as follows (only part of the display is removed):

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Server Environment Information "C # code get"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.