السلام عليكم
اريد كود يوضح لي على شكل بوليان(صح* خطأ)
هل ON LINE
أو OFF LINE
السلام عليكم
اريد كود يوضح لي على شكل بوليان(صح* خطأ)
هل ON LINE
أو OFF LINE
عفواً
تم اضافة هذه المشاركة بالخطأ
ارجو الحذف........
ارجو ان يكون اكود VB....
هذا الكود مطلوب ... ارجو من الاخوة الذين لديهم حل المساعدة
تم تعديل هذه المشاركة بواسطة ابوطلال في 18 أغسطس 2007 في 08:53
وجدت الحل .....
الحل كالتالي:
========================================
Public Const LanConnection As Integer = &H2S
Public Const ProxyConnection As Integer = &H4S
Public Const ModemConnection As Integer = &H1S
Public Const RasInstalled As Integer = &H10S
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Integer, ByVal dwReserved As Integer) As Integer
=====================================
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim dwflags As Integer
(Call InternetGetConnectedState(dwflags, 0
Label1.Text = dwflags And ModemConnection المودم
( Label2.Text = InternetGetConnectedState(0, 0 الانترنت
Label3.Text = dwflags And ProxyConnection البروكسي
Label4.Text = dwflags And LanConnection كيبل الشبكة
End Sub
qwertyuiop كتب:وجدت الحل .....الحل كالتالي:
========================================
Public Const LanConnection As Integer = &H2S
Public Const ProxyConnection As Integer = &H4S
Public Const ModemConnection As Integer = &H1S
Public Const RasInstalled As Integer = &H10S
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Integer, ByVal dwReserved As Integer) As Integer
=====================================
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim dwflags As Integer
(Call InternetGetConnectedState(dwflags, 0
Label1.Text = dwflags And ModemConnection المودم
( Label2.Text = InternetGetConnectedState(0, 0 الانترنت
Label3.Text = dwflags And ProxyConnection البروكسي
Label4.Text = dwflags And LanConnection كيبل الشبكة
End Sub
طبعاً...
نتجية التشغيل :
0 = تعني : ان الاتصال غير ممكن .
1 = تعني :ان الاتصال ممكن .
ارجو لكم التوفيق....
يعطيك العافية
انا جربت الكود لكن وجدت مشكلة وهي عندما تكون متصل بكيبل شبكة وليس لديك نت يعطيك رسالة انك متصل بالنت مع العلم ان الاشتراك منتهي
وهناك كود اسهل بالاعتماد على الفرييم ويرك كالتالي
Public Function TestCon() As Boolean
If My.Computer.Network.IsAvailable Then
Return True
Else
Return False
End If
End Function
ولكن لازت المشكلة موجودة
هناك حل أسهل وهو:
1.اعمل بالكود أداة Browser
2.خليها تحاول تفتح صفحة أساسية (لايمكن أن تكون Off Line) مثل www.gooogle.com
3. ان عرفت فانت On Line والا فلا
هذه دالة تختبر الاتصال بالانترنت
Public Function IsConnectionAvailable() As Boolean
' Returns True if connection is available
' Replace www.yoursite.com with a site that
' is guaranteed to be online - perhaps your
' corporate site, or microsoft.com
Dim objUrl As New System.Uri("http://www.yoursite.com/")
' Setup WebRequest
Dim objWebReq As System.Net.WebRequest
objWebReq = System.Net.WebRequest.Create(objUrl)
Dim objResp As System.Net.WebResponse
Try
' Attempt to get response and return True
objResp = objWebReq.GetResponse
objResp.Close()
objWebReq = Nothing
Return True
Catch ex As Exception
' Error, exit and return False
objWebReq = Nothing
Return False
End Try
End Functionمحترف فيجوال بيسك دوت نت وأوراكل كتب:هذه دالة تختبر الاتصال بالانترنتPublic Function IsConnectionAvailable() As Boolean ' Returns True if connection is available ' Replace www.yoursite.com with a site that ' is guaranteed to be online - perhaps your ' corporate site, or microsoft.com Dim objUrl As New System.Uri("http://www.yoursite.com/") ' Setup WebRequest Dim objWebReq As System.Net.WebRequest objWebReq = System.Net.WebRequest.Create(objUrl) Dim objResp As System.Net.WebResponse Try ' Attempt to get response and return True objResp = objWebReq.GetResponse objResp.Close() objWebReq = Nothing Return True Catch ex As Exception ' Error, exit and return False objWebReq = Nothing Return False End Try End Function
يعطيك العافية وجميع الاخوان الافاضل
هذا الموضوع مغلق.