Introduction:
This article describe Get Computer Details of your Windows Operating System in ASP.Net.
Description:
This article in i will explain get your computer desktop detail in your asp.net application.
ASPX:
This article describe Get Computer Details of your Windows Operating System in ASP.Net.
Description:
This article in i will explain get your computer desktop detail in your asp.net application.
ASPX:
<form id="form1" runat="server"> <div> <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" /> </asp:GridView> </div> </form>
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.
CS:
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"]; dt.Rows.Add(dr); } GridView1.DataSource = dt; GridView1.DataBind(); } }
0 comments :
Post a Comment