Skip to content

Commit

Permalink
Optimized MACAddress code
Browse files Browse the repository at this point in the history
  • Loading branch information
FullmetalCracker committed Apr 27, 2011
1 parent 8385c64 commit 414dbb9
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions sub/Util/Misc/HardwareInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,16 @@ public static string GetMACAddress()
{
ManagementObjectCollection instances =
new ManagementClass("Win32_NetworkAdapterConfiguration").GetInstances();
string str1 = string.Empty, str2 = string.Empty;
foreach (ManagementObject obj2 in instances)
{
if (!str2.Equals(string.Empty)) continue;
if (Convert.ToBoolean(obj2["IPEnabled"]))
{
str1 = obj2["MacAddress"].ToString();
return obj2["MacAddress"].ToString();
}
obj2.Dispose();
}

/*Not needed, MAC address was already in an acceptable format
//put the standard dashes in the MAC
for (int i = 0; i < str1.Length; i++)
{
//Note: the ToString() call is nessisary or it trys to add the chacter values instead of concating them
str2 += str1[i].ToString() + str1[++i].ToString() + "-";
}
str2 = str2.Remove(str2.Length - 1);*/
return str2;
return String.Empty;
}

public static bool IsValidIso88591(byte value)
Expand Down

0 comments on commit 414dbb9

Please sign in to comment.