Solved

serial number of harddisk

Posted on 2007-11-28
3
876 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thankx.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
A short article about problems I had with the new location API and permissions in Marshmallow
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

771 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

10 Experts available now in Live!

Get 1:1 Help Now