Question : Capturing Machine Address in VB.NET

Hi all

We wish to capture machine unique address/id  for the Hard Disk and/or  Mother Board etc. and based on that we wish to develop business application in Visual Studio 2005 using VB.NET.

Kindly guide which Framework class would be suitable for that. We donot mind using C# also if required.

Regards

Suresh Bansal


Answer : Capturing Machine Address in VB.NET

Take a look at https://answers.google.com/answers/main?cmd=threadview&id=122945

Here you can find a discussion about a unique pc-identifier.

(the final conclusion I see, is that there is no unique identifier)

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22633465.html
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
A] in order to find the MAC Address of your network card...
1.- You need to make a refference to System.Management dll
2.- at the top of you class type
Imports System.Management
Public Class Form1
3-Function
Private Function get_MACAdd() as string
        Dim pcMacAddress As String = ""
        Dim mc As System.Management.ManagementClass
        Dim mo As ManagementObject
        mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
        Dim moc As ManagementObjectCollection = mc.GetInstances()
        For Each mo In moc
            If mo.Item("IPEnabled") = True Then
                pcMacAddress &= "MAC address " & mo.Item("MacAddress").ToString() & vbCrLf
            End If
        Next
        '// MsgBox(pcMacAddress)
      return pcMacAddress
End Function
MAC Address is unique, but if you ever change your network card there another MAC Address
 
B] Also your PC-Name is unique on the network
 dim myPCName as string=getWorkStation().ToLower
    Public Function getWorkStation() As String
        Dim aStr As String = "none"
        Try
            Dim RegKey As Microsoft.Win32.RegistryKey
            RegKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("HARDWARE\DESCRIPTION\System", False)
            aStr = Environment.MachineName
            RegKey.Close()
        Catch ex As Exception
        End Try
        Return aStr
    End Function
-or- a better way
        Dim myPCName As String = System.Environment.MachineName.ToString.ToLower
        MsgBox(myPCName)
 
C] Finally this is a unique id
Dim myUniqeID as string=createUniqueCode(ctype(weekday(today),string))
    Public Function createUniqueCode(ByVal aStr As String) As String
        Dim c As String = ""
        Dim xTimer As String = Microsoft.VisualBasic.DateAndTime.Timer.ToString.Replace(",", "")
        Try
            Dim mName As String = ""
            If System.Environment.MachineName.ToString.Length > 0 Then
                If System.Environment.MachineName.ToString.Length < 4 Then
                    mName = Mid(System.Environment.MachineName.ToString & "abc", 1, 3)
                Else
                    mName = Mid(System.Environment.MachineName.ToString, 1, 3)
                End If
            Else
                If xTimer.Length > 0 Then
                    If xTimer.Length < 4 Then
                        mName = Mid(xTimer & "098", 1, 3)
                    Else
                        mName = xTimer
                    End If
                Else
                    mName = "que"
                End If
            End If
            c = Microsoft.VisualBasic.DateAndTime.Year(Today) & Microsoft.VisualBasic.DateAndTime.Month(Today) & Microsoft.VisualBasic.DateAndTime.Day(Today) & "-" & xTimer & mName & aStr
        Catch ex As Exception
            c = "sfjsdjfsdjasdas4123ortret8mf0984131" & DaysName(Today)
        Finally
        End Try
        Return c
    End Function
Random Solutions  
 
programming4us programming4us