本文介绍了获取虚拟机的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想获取安装了应用程序的VMWare的IP地址

谢谢

jeremy

Hi,

I would want to get the IP adress of the VMWare on which the application is installed

thanks

jeremy

推荐答案


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            ManagementClass managementClass = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection managementObjectCollection = managementClass.GetInstances();
            foreach (ManagementObject managementObject in managementObjectCollection)
            {
                if ((bool)managementObject["ipEnabled"])
                {
                    string[] ipaddresses = (string[])managementObject["IPAddress"];
                }
            }
        }
    }
}



有关更多详细信息,请查看本文:
使用WMI和C#配置TCP/IP设置 [ ^ ]

希望这能回答您的查询.

瓦莱里.



for more details you can look at this article:
Configuring TCP/IP Settings using WMI and C#[^]

Hope this is answering your query.

Valery.


这篇关于获取虚拟机的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:38
查看更多