Breaking News
Loading...
Wednesday 13 March 2013

How to get computer name using c#.net

1.  for getting information about your pc  you have to add one reference to it.
2.  you have to use System.Management;

so now add reference ,go to reference tab write click on it




3. click on to add reference tab.,  this will show below dialog box.



4.  now click on ok buttton now same way add one more reference like "System.Web.Services".
5. now add new name space

             using System.Management;
                 using System.Web.Services.Protocols;

6. now apply following code.

/////////////////////  CODE    ///////////////////////////

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;
using System.Web.Services.Protocols;

namespace Drive_Information
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
          string computerName=  System.Net.Dns.GetHostName();
          lblComputerName.Text = computerName;

        }
     }
}
////////////////////////////////////////////////////

Download code: PCnameCshap.rar
See Also :
  Follow Me On Facebook

--
/\/ir@\/  <(.'.)>

0 comments:

Post a Comment

Thanks for comment

 
Toggle Footer