Hi I'm using this code to generate machine signature. But it's take noticeable time to execute. Wonder why it's that slow ? Any faster method recommended ?
Public Shared Function DriveSN(ByVal DriveLetter As String) As String
Dim disk As ManagementObject = New ManagementObject(String.Format("Win32_Logicaldisk='{0}'", DriveLetter))
Dim VolumeName As String = disk.Properties("VolumeName").Value.ToString()
Dim SerialNumber As String = disk.Properties("VolumeSerialnumber").Value.ToString()
Return SerialNumber.Insert(4, "-")
End Function
Private Shared msig As String = Nothing
Public Shared Function MachineSignature() As String
If msig Is Nothing Then
Dim list As New List(Of String)
For Each d As DriveInfo In DriveInfo.GetDrives()
If (d.IsReady) Then
list.Add(DriveSN(d.Name.Substring(0, 2)))
End If
Next
msig = String.Join(" & ", list.ToArray())
End If
Return msig
End Function