SEBWIN-717, #637: Fixed loading of MAC address for system info.
This commit is contained in:
parent
b36df9ad5a
commit
d76dbf6b40
1 changed files with 7 additions and 16 deletions
|
@ -219,31 +219,22 @@ namespace SafeExamBrowser.SystemComponents
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var searcher = new ManagementObjectSearcher("SELECT MACAddress FROM Win32_NetworkAdapterConfiguration WHERE DNSDomain IS NOT NULL"))
|
using (var searcher = new ManagementObjectSearcher("SELECT MACAddress FROM Win32_NetworkAdapterConfiguration WHERE DNSHostName IS NOT NULL"))
|
||||||
using (var results = searcher.Get())
|
using (var results = searcher.Get())
|
||||||
|
using (var networkAdapter = results.Cast<ManagementObject>().First())
|
||||||
{
|
{
|
||||||
if (results != default && results.Count > 0)
|
foreach (var property in networkAdapter.Properties)
|
||||||
{
|
{
|
||||||
using (var networkAdapter = results.Cast<ManagementObject>().First())
|
if (property.Name.Equals("MACAddress"))
|
||||||
{
|
{
|
||||||
foreach (var property in networkAdapter.Properties)
|
MacAddress = Convert.ToString(property.Value).Replace(":", "").ToUpper();
|
||||||
{
|
|
||||||
if (property.Name.Equals("MACAddress"))
|
|
||||||
{
|
|
||||||
MacAddress = Convert.ToString(property.Value).Replace(":", "").ToUpper();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
MacAddress = UNDEFINED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception)
|
finally
|
||||||
{
|
{
|
||||||
MacAddress = UNDEFINED;
|
MacAddress = MacAddress ?? UNDEFINED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue