本文介绍了如何使用C#在WPF pc应用程序中监控以太网电缆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 设备是否连接,它将显示状态和最后连接,新连接如。并且还要区分IP地址。 whether the devices connected or not and it will show status and last connection ,new connection like. and also defferentiate ip addresss.namespace network_status{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void btn_Click(object sender, EventArgs e) { bool connection = NetworkInterface.GetIsNetworkAvailable(); if (connection == true) { MessageBox.Show("available"); } else { MessageBox.Show("not available"); } } 我尝试过: 命名空间network_status { ///< summary> / // MainWindow.xaml的交互逻辑 /// 公共部分类MainWindow:Window { public MainWindow() { InitializeComponent(); } private void btn_Click(object sender,EventArgs e) { bool connection = NetworkInterface.GetIsNetworkAvailable(); if(connection == true) { MessageBox.Show(available); } else { MessageBox.Show(not available); } } What I have tried:namespace network_status{ /// <summary> /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void btn_Click(object sender, EventArgs e) { bool connection = NetworkInterface.GetIsNetworkAvailable(); if (connection == true) { MessageBox.Show("available"); } else { MessageBox.Show("not available"); } }推荐答案 你有一个很大的愿望清单 - 我不知道'defferentiate ip address',但是,这个如何使用Windows NLM API获得新网络连接的通知 [ ^ ]是让系统告诉你网络连接/断开连接事件的一种方法you have a big wish list - I dont know about 'defferentiate ip address', but, this How to use the Windows NLM API to get notified of new network connectivity[^] is one way of having the system tell you about network connect/disconnect events 这篇关于如何使用C#在WPF pc应用程序中监控以太网电缆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-31 09:56