惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - Hm

敏捷开发中asp.net mvc3编写的正确顺序 WF4.0入门系列2——用代码创建一个简单的工作流 WF4.0入门系列 WF4.0入门系列1——创建一个简单的工作流 C#解析xml代码 - Hm - 博客园 什么是依赖注入 找不到可安装的ISAM错误 - Hm - 博客园 ASP.NET下用相对路径访问ACCESS数据解决方案 使vs2008支持extjs智能提示功能 VS2005文件自动定位功能 微软VSTS 2005 试用版注册为正式版的方法 敏捷开发感悟 敏捷开发笔记(二) 敏捷开发笔记(一) VS 2008 and .NET 3.5 Beta 2 发布了 动态权限树控件 DWR简介 WebWork Processors Then and Now
得到本机的IP地址和MAC地址的工具类
Hm · 2007-07-18 · via 博客园 - Hm

类代码如下:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Management;
using System.Net; 

namespace Operationlayer
{
    public class IpMacInformation
    {
        /// <summary>
        /// 得到主机的IP地址
        /// </summary>
        /// <returns>IP地址的字符串</returns>
        public String GetHostIp(){
        string strIP = "";
        System.Net.IPAddress[] addressList = Dns.GetHostByName(Dns.GetHostName()).AddressList;
        for(int i = 0; i < addressList.Length; i++)
        {
            strIP += addressList[i].ToString() + "\n";
        }
        return strIP;
}

///   <summary>
/// 得到取第一块网卡的MAC地址
/// </summary>  
///   <returns>返回网卡MAC地址的字符串<</returns>  

        public string GetHostMac()
        {   //注意必须在解决方案中添加引用System.Mangement的引用
            string szMac = "";
            ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection moc = mc.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                if ((bool)mo["IPEnabled"] == true)
                {
                    szMac = mo["MacAddress"].ToString().Replace(":", "-");
                    break;  //如果你要获取多块网卡MAC地址,可以把break去掉
                }
            }
            return szMac;
        }
    }
}