找传奇、传世资源到传世资源站!

DotRas 获取ip地址 示例源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

DotRas 获取ip地址 示例源码 C#语言基础-第1张using System;using System.Windows.Forms;namespace DotRas.Samples.GetActiveConnectionIPAddress{ public partial class MainForm : Form { public MainForm() { InitializeComponent(); } private void LoadConnectionsComboBox() { this.ConnectionsComboBox.Items.Add(new ComboBoxItem("Choose one...", null)); foreach (RasConnection connection in RasConnection.GetActiveConnections()) { this.ConnectionsComboBox.Items.Add(new ComboBoxItem(connection.EntryName, connection.EntryId)); } this.ConnectionsComboBox.SelectedIndex = 0; } private void MainForm_Load(object sender, EventArgs e) { this.LoadConnectionsComboBox(); } private void GetAddressButton_Click(object sender, EventArgs e) { foreach (RasConnection connection in RasConnection.GetActiveConnections()) { if (connection.EntryId == (Guid)((ComboBoxItem)this.ConnectionsComboBox.SelectedItem).Value) { RasIPInfo ipAddresses = (RasIPInfo)connection.GetProjectionInfo(RasProjectionType.IP); if (ipAddresses != null) { this.ClientAddressTextBox.Text = ipAddresses.IPAddress.ToString(); this.ServerAddressTextBox.Text = ipAddresses.ServerIPAddress.ToString(); } } } } private void ConnectionsComboBox_SelectedIndexChanged(object sender, EventArgs e) { this.GetAddressButton.Enabled = this.ConnectionsComboBox.SelectedIndex > 0; } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复