zoukankan      html  css  js  c++  java
  • 获取IP

    public string GetIPAddress()
    {
    try
    {
    string sIP = string.Empty; //获取IP地址
    _mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
    _moc = _mc.GetInstances();
    foreach (ManagementObject mo in _moc)
    {
    if ((bool)mo["IPEnabled"] == true)
    {
    Array ar;
    ar = (System.Array)(mo.Properties["IpAddress"].Value);
    sIP = ar.GetValue(0).ToString();
    if (sIP == "0.0.0.0") continue;
    break;
    }
    }
    _moc = null;
    _mc = null;
    return sIP;
    }
    catch { return string.Empty; }
    }

  • 相关阅读:
    3.31上午英语视频
    3.30上午
    leetcode 38
    leetcode 36
    leetcode 28
    leetcode 27
    leetcode 26
    leetcode 24
    leetcode 21
    leetcode 20
  • 原文地址:https://www.cnblogs.com/sunlunhao/p/5157873.html
Copyright © 2011-2022 走看看