Solved

serial number of harddisk

Posted on 2007-11-28
3
877 Views
Last Modified: 2013-11-26
how can we get serial number of harddisk in vb.net 2005 and computer id or a mac address
0
Comment
Question by:16700
  • 2
3 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20370025
Consider that a computer can have more than one harddisk or mac address.
For MAC address, you can retrieve the list of MACs this way:

           List<string> Nics = new List<string>();

            NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface nic in adapters)
            {
                NetworkInterfaceType type= nic.NetworkInterfaceType;
                if (type!= NetworkInterfaceType.Loopback && type!= NetworkInterfaceType.Tunnel && type!= NetworkInterfaceType.Unknown)
                {
                    this.Nics.Add(nic.GetPhysicalAddress().ToString());
                }
            }
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20370079
Sorry, that was C# code. Here is the vb.net code:

Dim Nics As New List(Of String)()

Dim adapters As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
For Each nic As NetworkInterface In adapters
    Dim type As NetworkInterfaceType = nic.NetworkInterfaceType
    If type <> NetworkInterfaceType.Loopback AndAlso type <> NetworkInterfaceType.Tunnel AndAlso type <> NetworkInterfaceType.Unknown Then
        Me.Nics.Add(nic.GetPhysicalAddress().ToString())
    End If
Next

you will need also:

Imports System.Net
Imports System.Net.NetworkInformation

0
 

Author Closing Comment

by:16700
ID: 31411561
Thankx.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
A short article about problems I had with the new location API and permissions in Marshmallow
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now