Skip to content

Commit 9083fdb

Browse files
committed
Fix #424
1 parent 1a3fa52 commit 9083fdb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

CompactGUI/Helper.vb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,20 @@ Module Helper
3434

3535

3636
Function getUID() As String
37-
3837
Dim MacID As String = String.Empty
3938
Dim mc As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
4039
Dim moc As ManagementObjectCollection = mc.GetInstances()
4140
For Each mo As ManagementObject In moc
42-
If (MacID = String.Empty And CBool(mo.Properties("IPEnabled").Value) = True) Then
43-
MacID = mo.Properties("MacAddress").Value.ToString()
41+
42+
If mo.Properties("IPEnabled") IsNot Nothing AndAlso mo.Properties("IPEnabled").Value IsNot Nothing Then
43+
44+
If CBool(mo.Properties("IPEnabled").Value) = True AndAlso mo.Properties("MacAddress") IsNot Nothing AndAlso mo.Properties("MacAddress").Value IsNot Nothing Then
45+
MacID = mo.Properties("MacAddress").Value.ToString()
46+
Exit For
47+
End If
4448
End If
4549
Next
4650
Return Convert.ToBase64String(Encoding.UTF8.GetBytes(MacID))
47-
4851
End Function
4952

5053

0 commit comments

Comments
 (0)