How to obtain the current operating system, IIS version, and Framework Version

Source: Internet
Author: User

Namespace consoleapplication1
{
Class Program
{
Static void main (string [] ARGs)
{
Systeminfo info = new systeminfo ();
Console. writeline (info. pcname );
Console. writeline (info. IIS );
// Console. writeline (info. osversion );
Console. writeline (info. Framework );
Console. Readline ();
}
}

Public class systeminfo
{
// Operating system name
Private string pcname;
Public String pcname
{
Get
{
// Obtain it if the operating system is empty
If (string. isnullorempty (this. pcname ))
{
Registrykey rk;
Rk = registry. localmachine. opensubkey ("SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion ");
This. pcname = rk. getvalue ("productname"). tostring ();
}
Return "Current Operating System:" + this. pcname;
}
}

Private int osversion;
Public int osversion
{
Get
{
If (osversion = 0)
{
Registrykey rk;
Rk = registry. localmachine. opensubkey ("SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion ");
Int. tryparse (rk. getvalue ("currentbuildnumber"). tostring (), out this. osversion );
}

Return this. osversion;
}
}

// IIS Version Number
Private string IIS;
Public String IIS
{
Get
{
// Obtain if IIS is empty
If (string. isnullorempty (this. IIS ))
{
Registrykey key = registry. localmachine. opensubkey (@ "SOFTWARE \ Microsoft \ inetstp ");
This. IIS = "IIS" + key. getvalue ("majorversion"). tostring ();
}
Return "IIS Version:" + this. IIS;
}
}

// Framework Version
Private string framework;
Public String framework
{
Get
{
// Obtain if the Framework version is empty
If (string. isnullorempty (this. Framework ))
{
Version V = environment. version;
If (V! = NULL)
{
This. Framework = V. Major + "." + v. Minor;
}
}
Return "Framework Version: Framework" + this. Framework;
}
}
}
}

How to obtain the current operating system, IIS version, and Framework Version

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.