22 Aralık 2012 Cumartesi

INTERNET BAGLANTI DURUMUNU OGRENMEK

INTERNET BAGLANTI DURUMUNU OGRENMEK

Bu kod sayesinde internete bagli olup olmadigimiz ögrenilebilir 
Option Explicit
Private Declare Function RasEnumConnections Lib \"RasApi32.dll\" _
Alias \"RasEnumConnectionsA\" (lpRasCon As Any, lpcb As _
Long, lpcConnections As Long) As Long
Private Declare Function RasGetConnectStatus Lib \"RasApi32.dll\" _
Alias \"RasGetConnectStatusA\" (ByVal hRasCon As Long, _
lpStatus As Any) As Long
Const RAS_MaxEntryName = 256
Const RAS_MaxDeviceType = 16
Const RAS_MaxDeviceName = 32
Private Type RASType
dwSize As Long
hRasCon As Long
szEntryName(RAS_MaxEntryName) As Byte
szDeviceType(RAS_MaxDeviceType) As Byte
szDeviceName(RAS_MaxDeviceName) As Byte
End Type
Private Type RASStatusType
dwSize As Long
RasConnState As Long
dwError As Long
szDeviceType(RAS_MaxDeviceType) As Byte
szDeviceName(RAS_MaxDeviceName) As Byte
End Type
Private Sub Form_Load()
Timer1.Interval = 200
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
DFÜStatus
End Sub
Private Function DFÜStatus() As Boolean
Dim RAS(255) As RASType, RASStatus As RASStatusType
Dim lg&, lpcon&, Result&
RAS(0).dwSize = 412
lg = 256 * RAS(0).dwSize
Result = RasEnumConnections(RAS(0), lg, lpcon)
If lpcon = 0 Then
Label1.Caption = \"Offline\" \'###
DFÜStatus = False
Else
RASStatus.dwSize = 160
Result = RasGetConnectStatus(RAS(0).hRasCon, RASStatus)
If RASStatus.RasConnState = &H2000 Then
Label1.Caption = \"Online\" \'###
DFÜStatus = True
Else
Label1.Caption = \"Baglanti Kopuk\" \'###
DFÜStatus = False
End If
End If
End Function 

Hiç yorum yok:

Yorum Gönder