Veröffentlicht 27. Oktober 200816 j Hallo ich würde gerne wissen,wie man eine anwendung programiert die mir anzeigt ob man mit dem Netzwerk verbunden ist. Am besten wie man es Grafisch lösen kann mit einem Ratio Button oder so was in der art? Ich will nur Einfach in meinem Program sichbar machen ob LAN verbindung besteht... Muss dazu sagen bin anfänger, falls einer denkt das es zu easy ist
27. Oktober 200816 j Schau ma hier: How to check for a network connection in .NET 2.0 (C# or VB) -- Ardent Dev Wegen der grafischen Darstellung. Da kannste ja je nachdem ob True oder False angezeigt wird ein bestimmtes Bild auf Visible=True schalten. Z.B. wenn eine Verbindung da ist haste eine Grafik die Grün ist.
28. Oktober 200816 j hmmm funzt nicht so wie ich wollte habe es mal mit das hier versucht: Geht aber auch nicht ich bekomme es nicht graphisch hin.., /* Deklaration der API-Funktion InternetGetConnectedStateEx */ [DllImport("wininet.dll")] private static extern int InternetGetConnectedStateEx(out int lpdwFlags, StringBuilder lpszConnectionName, int dwNameLen, int dwReserved); /* Konstanten für InternetGetConnectedStateEx */ private const int INTERNET_CONNECTION_MODEM = 0x01; private const int INTERNET_CONNECTION_LAN = 0x02; private const int INTERNET_CONNECTION_PROXY = 0x04; private const int INTERNET_RAS_INSTALLED = 0x10; private const int INTERNET_CONNECTION_OFFLINE = 0x20; private const int INTERNET_CONNECTION_CONFIGURED = 0x40; /* Klasse für die Rückgabe des Internet-Verbindungsstatus */ public class InternetConnectionState { // Der Name der Verbindung public string Name; // Info, ob die Verbindung online ist public bool Online; // Info, ob die Verbindung konfiguriert ist public bool Configured; // Info, ob eine Modem-Verbindung besteht (auch ISDN und DSL) public bool ModemConnection; // Info, ob die Verbindung über das LAN erfolgt (z. B. bei TDSL) public bool Lan; // Info, ob die Verbindung über einen Proxy erfolgt public bool ProxyConnection; // Info, ob RAS installiert ist public bool RASInstalled; // Info, ob das System im Offline-Modus ist public bool Offline; } /* Methode zur Ermittlung der Art der aktuellen Internetverbindung */ public static InternetConnectionState GetInternetConnectionState() { // InternetConnectionState-Instanz erzeugen InternetConnectionState ics = new InternetConnectionState(); // Verbindungsstatus abfragen StringBuilder icsName = new StringBuilder(1024); int flags; ics.Online = (InternetGetConnectedStateEx(out flags, icsName, 1024, 0) != 0); ics.Name = icsName.ToString(); ics.Configured = ((flags & INTERNET_CONNECTION_CONFIGURED) > 0); ics.Lan = ((flags & INTERNET_CONNECTION_LAN) > 0); ics.ModemConnection = ((flags & INTERNET_CONNECTION_MODEM) > 0); ics.Offline = ((flags & INTERNET_CONNECTION_OFFLINE) > 0); ics.ProxyConnection = ((flags & INTERNET_CONNECTION_PROXY) > 0); ics.RASInstalled = ((flags & INTERNET_RAS_INSTALLED) > 0); // Das InternetConnectionState-Objekt zurückgeben return ics; }
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.