PPP Adapter and IP Address

CoachBarker

Well-known member
Joined
Jul 26, 2007
Messages
133
Programming Experience
1-3
This is in regards to the Remote Desktop Application I am creating in VS 2005 using vb.net.

I have found out that it is not possible to detect if a VPN is running on a computer through code. With the help of people in various forums I was able to produce the code that would check running processes, but a VPN is not one of them.

So the other thought was to check and see if they were connected to the database that this application was going to use, turns out you can connect to the database without using the VPN, so that idea was out.

But it is possible to check the IP address of the local computer and capture that. That I figured out how to do.

VB.NET:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim strIPAddress As String = ""
        Dim IPAddressList As System.Net.IPAddress()
        IPAddressList = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList
        Dim i As Integer
        For i = 0 To IPAddressList.Length - 1
            strIPAddress += IPAddressList(i).ToString()
        Next i
        TextBox3.Text = strIPAddress
    End Sub
And this returns the IP Address to the text box and for now that is good enough, but what I need to do is capture the IP Address using the PPP Adapter so I can compare it to what it should be to show they are connected. As an example here is what I get if I connect to the VPN from home and run IPConfig:

Ethernet adapter Local Area Connection:

IP Address 192.168.1.100
Subnet Mast 255.255.255.0
Default Gateway 192.168.1.1


PPP Adapter XXXXXX XXXXXX VPN:

IP Address 128.230.90.64
Subnet Mast 255.255.255.0
Default Gateway

Any help would be greatly appreciated as always:D
CoachBarker
 
Resolved it by doing this instead

VB.NET:
 Private Sub btnVPNIsRunning_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVPNIsRunning.Click
        Dim NetworkInterfaces() As System.Net.NetworkInformation.NetworkInterface
        NetworkInterfaces = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
        For Each cInterface As System.Net.NetworkInformation.NetworkInterface In NetworkInterfaces
            If cInterface.NetworkInterfaceType = Net.NetworkInformation.NetworkInterfaceType.Ppp Then
                TextBox7.Text = (cInterface.GetIPProperties.UnicastAddresses.Item(0).Address.ToString())
            End If
        Next
    End Sub

Parts I got elsewhere and modified,
Thank God for the forums
CoachBarker
 
Back
Top