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:
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