Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Use – initialize - get the platform – version – versionString - servicePack of operating system using operating system class vb.net - C# .net.

Author: Maliha Atteeq
Download Source Code : 1007_operatingSystemApps.zip

In this simple article you will learn that how to use, initialize, get the platform, version, and versionString, servicePack of operating system using operating system class in vb and C #.net.

 Operating system:

Operating system class represents information about an operating system, such as the version and platform identifier. This class cannot be inherited.

Initialization:

In order to initialize the object of operating system, operating system class provides us one constructor.

The constructor takes two arguments as a parameter; one is the platform of type platformId and second is the version of type version.

To demonstrate make a new window application. Drag one button on from.

Now write the following code on Button click event:

C#:

private void btn_build_Click(object sender, EventArgs e)

        {

            PlatformID plat = PlatformID.Win32NT;

            Version ver = new Version("2.4.6.10");

            System.OperatingSystem obj = new OperatingSystem(plat, ver);

            MessageBox.Show("operating system is build having platform= "+Convert.ToString(plat)+"and version= "+Convert.ToString(ver));

        }

 

VB:

Private Sub btn_build_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim plat As PlatformID = PlatformID.Win32NT

        Dim ver As New Version("2.4.6.10")

        Dim obj As System.OperatingSystem = New OperatingSystem(plat, ver)

        MessageBox.Show(("operating system is build having platform= " & Convert.ToString(plat) & "and version= ") + Convert.ToString(ver))

    End Sub

Get the platform:

In order to get the platform of the operating system, operating system class provides us a property named as platform. This property retuns the plat form as the return type of it is platformid. So it return the object of type platformId depicting the platform of your operating system.

 

To demonstrate make a new window application. Drag one button on from.

Now write the following code on Button click event:

C#:

private void btn_getPlat_Click(object sender, EventArgs e)

        {

            PlatformID plat;

            plat = obj.Platform;

            MessageBox.Show("the platform is "+Convert.ToString(plat));

           

        }

VB:

Private Sub btn_getPlat_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim plat As PlatformID

        plat = obj.Platform

 

        MessageBox.Show("the platform is " & Convert.ToString(plat))

    End Sub

Get the version:

In order to get the version of the operating system, operating system class provides us a property named as version. This property returns the version as the return type of it is version. So it returns the object of type version depicting the version of your operating system.

To demonstrate make a new window application. Drag one button on from.

Now write the following code on Button click event:

C#:

private void btn_getVer_Click(object sender, EventArgs e)

        {

            Version version;

            version = obj.Version;

            MessageBox.Show("the version is " + Convert.ToString(version));

 

        }

VB:

Private Sub btn_getVer_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim version As Version

        version = obj.Version

 

        MessageBox.Show("the version is " & Convert.ToString(version))

    End Sub

 

 

Get the ServicePack version:

In order to get the service pack version of the operating system, operating system class provides us a property named as servicePack. This property returns the string as the return type of it is string. That string depicts the servicePackversion of your operating system.

To demonstrate make a new window application. Drag one button on from.

Now write the following code on Button click event:

C#:

private void button1_Click(object sender, EventArgs e)

        {

            String temp;

            temp=obj.ServicePack;

            MessageBox.Show("the servicepack is " + temp);

 

        }

VB:

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim temp As [String]

        temp = obj.ServicePack

        MessageBox.Show("the servicepack is " & temp)

    End Sub

 

Get the ServicePack version:

Version string gets the concatenated string representation of the platform identifier, version, and service pack that are currently installed on the operating system. In order to get the version string of the operating system, operating system class provides us a property named as versionString. This property returns the string as the return type of it is string. That string depicts the versionString of your operating system.

To demonstrate make a new window application. Drag one button on from.

Now write the following code on Button click event:

C#:

private void btn_getVerStr_Click(object sender, EventArgs e)

        {

            String ob;

            ob = obj.VersionString;

            MessageBox.Show("the version string is " + ob);

        }

VB:

Private Sub btn_getVerStr_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim ob As [String]

        ob = obj.VersionString

        MessageBox.Show("the version string is " & ob)

    End Sub

Now write the following code on FORM LOAD event:

C#:

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "DEVASP OPERATING SYSTEM APPLICATION";

        }

 

Vb:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)

        Me.Text = "DEVASP OPERATING SYSTEM APPLICATION"

    End Sub

This simple article tells that how to use, initialize, get the platform, version, and versionString, servicePack of operating system using operating system class in vb and C #.net.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Create - get culture - ordinal - invariant culture of string comparer using string comparer class vb.net - C# .net.

Disclaimer - Privacy
© 2002-2017 DevASP.net