2011年2月1日星期二

获取VPN拨号后的IP地址

 

private void GetVpnClientIp(){
           GetMetric();
           foreach (RasConnection connection in RasConnection.GetActiveConnections())
           {
               if (connection.EntryName == entry.Name)
               {
                   RasIPInfo ipAddresses = (RasIPInfo)connection.GetProjectionInfo(RasProjectionType.IP);
                  
                   interfaceIndex =Convert.ToUInt32(iphlpapi.GetAdaptersIndex());
                   if (ipAddresses != null)
                   {
                       //this.ClientAddressTextBox.Text = ipAddresses.IPAddress.ToString();
                       //this.ServerAddressTextBox.Text = ipAddresses.ServerIPAddress.ToString();
                       this.Ipbar.Text = ipAddresses.IPAddress.ToString();
                       this.ClientIp = ipAddresses.IPAddress.ToString();
                       this.ServerIp = ipAddresses.ServerIPAddress.ToString();
                   }
               }
           }
       }

没有评论:

发表评论