获取虚拟机的IP地址 [英] Get IP Adresse of the VM

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

问题描述



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

谢谢

jeremy

Hi,

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

thanks

jeremy

推荐答案

DNSGetHostName() [ ^ ]可能会有帮助.
DNSGetHostName()[^] might help.




您可以使用Windows Management Instrumentation(wmi)进行此操作.

Hi,

You could do this using windows management instrumentation (wmi).

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地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆