Autor Beitrag
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mi 02.11.05 19:18 
Hallo,
ich schreibe gerade an einem kleinen Tool, das eine bestimmte Netzwerkverbindung (genauer gesagt geht es um eine PPTP-VPN-Verbindung) prüfen soll. Den Namen der Verbindung habe ich schon per Registry rausbekommen.
Jetzt muss ich aber erstmal den Status der Verbindung überprüfen (verbunden oder nicht) und danach wäre es auch noch sehr geschickt, wenn ich die Verbindung auf- und abbauen könnte.

Weiß dazu jemand was?
UGrohne Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mi 02.11.05 23:47 
OK, auf die erste Frage habe ich nun eine Antwort gefunden. Das Folgende gilt aber laut MSDN anscheinend nur fuer das Framework 2.0!

Unter System.Net.NetworkInterface kann man alle aktiven Interfaces abfragen, dazu gehoeren auch VPN-Verbindungen:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
        private bool IsVPNConnected()
        {
            bool result = false;
            NetworkInterface[] netifs = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface netif in netifs)
            {
                if (netif.Name.Equals(VPNConnectionName))
                {
                    RTBnetlog.AppendText("\nConnection " + netif.Name + " is up");
                    result = true;
                }
            }
            return result;
        }

Dort werden aber inaktive leider nicht aufgelistet. Aber das finde ich vielleicht auch noch raus ;)