获取适配器带宽和可用IP地址
Getting Adapter bandwidth and Available IP Addresses
谁能告诉我如何才能获得网络适配器中的可用带宽和ip地址?首先我要告诉你我做了什么。我尝试了Windows管理工具(WMI)类的查询Win32_PerfFormattedData和Win32_PerfFormattedData_Tcpip_NetworkInterface。Win32_PerfFormattedData -从这个类我可以得到适配器的当前带宽。Win32_PerfFormattedData_Tcpip_NetworkInterface -从这个类中,我可以获得适配器中存在的ip地址。问题是,我不知道如何找到两者之间的关系,如果我在系统中有一个以上的网络适配器,因为我找不到这两个类属性之间的任何共同属性。请帮我解决这个问题。如果有任何其他方法获得当前带宽和网络适配器的Ip地址,欢迎提出建议。
使用Win32_NetworkAdapter
和Win32_NetworkAdapterConfiguration
代替。下面是简单的PowerShell脚本示例:
$objWMi = get-wmiobject -Query "Select * from Win32_NetworkAdapter where PhysicalAdapter = True"
foreach ($obj in $objWmi)
{
write-host "AdapterType:" $obj.AdapterType
write-host "Caption:" $obj.Caption
write-host "CommunicationStatus:" $obj.CommunicationStatus
write-host "Description:" $obj.Description
write-host "DeviceName:" $obj.DeviceName
write-host "MACAddress:" $obj.MACAddress
write-host "Speed:" $obj.Speed
write-host "Name:" $obj.Name
$config = get-wmiobject -Query "select * from Win32_NetworkAdapterConfiguration where InterfaceIndex = $($obj.InterfaceIndex)"
foreach($data in $config)
{
write-host "NetworkAddress:" $config.IPAddress
}
write-host
write-host "########"
write-host
}
在Windows 8及以后,你应该使用MSFT_NetAdapter
类而不是Win32_NetworkAdapter
。Win32_NetworkAdapterConfiguration
也只返回IPv4配置数据。
相关文章:
- 如何使用 Boost Asio 在 Android 上获取我的本地 udp IP 地址?
- C++ / Qt:如何检测主机名或IP地址何时引用当前系统?
- 使用 C++将 IP 地址附加到字符*
- 使用全局 IP 地址时,C++ winsock 2 应用程序中的代码是否必须更改?
- Rabbitmq 将本地主机更改为 IP 地址C++
- C++ - 使用代码块从文件中读取 IP 地址
- C 使用from_string创建IP地址的C 导致lambda错误
- 如何在解析过程中区分 IP 地址和域名
- 如何使用 asio 库获取 IP 地址的主机名
- IP地址匹配过滤功能
- 如何将C++ ulong 4 字节 IP 地址正确转换为 C# 类型
- 如何在NS3中设置节点的IP地址和数据?
- 如何从活动的 udp 连接获取远程 IP 地址和端口
- 无符号的 int 到 IP 地址字符串,不带 itoa/to_string/boost
- 如何在FD_SET内获取套接字的IP地址
- 使用Boost库中的PC中获取我的以太网设备IP地址的列表
- 使用静态IP地址时,ESP32 httpclient连接拒绝了
- C++检查有效的 IP 地址或 IP
- 如何使用 Poco::Net::HTTPSClientSession 绑定特定的源 IP 地址
- 如何在Windows上绕过主机文件获取真实的IP地址