.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Get the Desktop Details of Your Windows Operating System in ASP.Net

Posted By:Sanjeeb Lenka       Posted Date: September 09, 2013    Points: 200    Category: ASP.NET    URL: http://www.dotnetspark.com  

This article explains how to get the Desktop details of a user in your system.


This article explains how to get the Desktop details of a user in your system. Here I will get the information from the Win32_Desktop class.

What Win32_Desktop  is

The Win32_Desktop WMI class represents the common characteristics of a user's Desktop.

Create a new ASP.Net Empty website.

Add one page in that website.

In that page drag and drop a GridView control.

Design your screen as in the following screen:


Or you can copy the following source code:


    <form id="form1" runat="server">


        <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" >

            <AlternatingRowStyle BackColor="White" />

            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />

            <RowStyle BackColor="#EFF3FB" />





Next add a reference of "System.Management".

To add the reference use the following procedure.

Go to Solution Explorer, select the project and right-click on that and choose "Add Reference" from the menu.


A window will open; in that choose the ".Net" tab.


It will show a list. In that list, choose "System.Management" and click the "OK" Button.


Now go to code view and write the following code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Management;

using System.Data;

public partial class Default2 : System.Web.UI.Page


    protected void Page_Load(object sender, EventArgs e)


        DataTable dt = new DataTable();

        dt.Columns.Add(new DataColumn("Name", typeof(string)));

        dt.Columns.Add(new DataColumn("BorderWidth", typeof(string)));

        dt.Columns.Add(new DataColumn("CursorBlinkRate", typeof(string)));

        dt.Columns.Add(new DataColumn("DragFullWindows", typeof(string)));

        dt.Columns.Add(new DataColumn("IconTitleFaceName", typeof(string)));

        dt.Columns.Add(new DataColumn("IconTitleSize", typeof(string)));

        dt.Columns.Add(new DataColumn("IconTitleWrap", typeof(string)));

        dt.Columns.Add(new DataColumn("Pattern", typeof(string)));

        dt.Columns.Add(new DataColumn("ScreenSaverActive", typeof(string)));

        dt.Columns.Add(new DataColumn("WallpaperStretched", typeof(string)));

        SelectQuery Sq = new SelectQuery("Win32_Desktop");

        ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher(Sq);

        ManagementObjectCollection osDetailsCollection = objOSDetails.Get();

        foreach (ManagementObject MO in osDetailsCollection)


            DataRow dr = dt.NewRow();

            dr["Name"] = MO["Name"].ToString();

            dr["BorderWidth"] = MO["BorderWidth"].ToString();

            dr["CursorBlinkRate"] = MO["CursorBlinkRate"];

            dr["DragFullWindows"] = MO["DragFullWindows"];

            dr["IconTitleFaceName"] = MO["IconTitleFaceName"];

            dr["IconTitleSize"] = MO["IconTitleSize"];

            dr["IconTitleWrap"] = MO["IconTitleWrap"];

            dr["Pattern"] = MO["Pattern"];

            dr["ScreenSaverActive"] = MO["ScreenSaverActive"];

            dr["WallpaperStretched"] = MO["WallpaperStretched"];



        GridView1.DataSource = dt;



In the code above I get the information from Win32_Desktop and store it in a datatable and bind it to the grid.


It represents a WQL (WMI Query Language) SELECT data query.


It retrieves a collection of management objects based on a specified query.

This class is one of the more commonly used entry points to retrieving management information.


It represents various collections of management objects retrieved using WMI.

Now build your application, it will show all details in the Grid.


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend