C# - 运行 我的程序仅在选定的 mac 地址上
C# - Run my program only on selected mac address
我在我的项目中使用 C#,我想 运行 仅在选定的 计算机 上,我们已经使用 mac-address 检查计算机 mac-address 是否在列表中,如果不在,则显示类似的消息。
如何使用 C# 执行此操作?
if (listofmacaddress == true)
{
//run the program
}
else
{
MessageBox.Show("Invalid mac address, application close. ",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
public static bool listofmacaddress()
{
var mac = // get mac address
if(mac == "##########1")
return true;
else if(mac == "#########2")
return true;
else
return false;
}
像这样:
public string GetMACAddress()
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
string macAddress = string.Empty;
foreach (NetworkInterface adapter in nics)
{
if (macAddress == String.Empty)
{
var properties = adapter.GetIPProperties();
macAddress = adapter.GetPhysicalAddress().ToString();
}
} return macAddress;
}
我在我的项目中使用 C#,我想 运行 仅在选定的 计算机 上,我们已经使用 mac-address 检查计算机 mac-address 是否在列表中,如果不在,则显示类似的消息。
如何使用 C# 执行此操作?
if (listofmacaddress == true)
{
//run the program
}
else
{
MessageBox.Show("Invalid mac address, application close. ",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
public static bool listofmacaddress()
{
var mac = // get mac address
if(mac == "##########1")
return true;
else if(mac == "#########2")
return true;
else
return false;
}
像这样:
public string GetMACAddress()
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
string macAddress = string.Empty;
foreach (NetworkInterface adapter in nics)
{
if (macAddress == String.Empty)
{
var properties = adapter.GetIPProperties();
macAddress = adapter.GetPhysicalAddress().ToString();
}
} return macAddress;
}