PDA

View Full Version : شرط گزاری مربوط به اینترنت



albalooband
جمعه 14 فروردین 1388, 18:42 عصر
سلام
شرطی میخوام که:
اگر سیستم به اینترنت وصل بود . یک دکمه فعال بشه.(enable=true(
اینو واسه قسمتی از برنامم که برای ارسال نظره لازم دارم

Babak.Hassanpour
جمعه 14 فروردین 1388, 18:47 عصر
سلام دوست عزیز
قبل از هر چیز باید بدونید درست مطرح کردن سوال به پیدا کردن جواب کمک می کنه.
دوم اینکه جستجو کنید
مثلا اگه تو همین سایت عبارت اتصال به اینترنت رو جستجو می کردید به جواب می رسیدید.
به هرحال یک کم خودتون هم زحمت بکشید
اینم کد مورد نظر


Const NETWORK_ALIVE_AOL = &H4
Const NETWORK_ALIVE_LAN = &H1
Const NETWORK_ALIVE_WAN = &H2
Private Declare Function IsNetworkAlive Lib "SENSAPI.DLL" (ByRef lpdwFlags As Long) As Long

Private Sub Form_Load()
Dim CRes As Long
If IsNetworkAlive(CResult) = 0 Then
MsgBox " Not Connected to a Network!"
Else
MsgBox "Connected to a" & IIf(CRes = NETWORK_ALIVE_AOL, "AOL", IIf(CRes = NETWORK_ALIVE_LAN, "LAN", "WAN")) & "Network"
End If
End Sub

albalooband
چهارشنبه 19 فروردین 1388, 23:21 عصر
این کد شامل همه نوع اینترنت میشه؟ اگه برنامه تو محیطی که شبکه هست(ولی اینترنت نیست) باشه چطور؟

crazyfull
چهارشنبه 19 فروردین 1388, 23:32 عصر
Option Explicit
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
'Internet connection VIA Proxy server.
Public Const ProxyConnection As Long = &H4
'Modem is busy.
Public Const ModemConnectionIsBusy As Long = &H8
'Internet connection is currently Offline
Public Const InternetIsOffline As Long = &H20
'Internet connection is currently configured
Public Const InternetConnectionIsConfigured As Long = &H40
'Internet connection VIA Modem.
Public Const ModemConnection As Long = &H1
'Remote Access Server is installed.
Public Const RasInstalled As Long = &H10
'Internet connection VIA LAN.
Public Const LanConnection As Long = &H2

Public Function IsLanConnection() As Boolean
Dim dwflags As Long
'return True if LAN connection
Call InternetGetConnectedState(dwflags, 0&)
IsLanConnection = dwflags And LanConnection
End Function


Public Function IsModemConnection() As Boolean
Dim dwflags As Long
'return True if modem connection.
Call InternetGetConnectedState(dwflags, 0&)
IsModemConnection = dwflags And ModemConnection
End Function


Public Function IsProxyConnection() As Boolean
Dim dwflags As Long
'return True if connected through a proxy.
Call InternetGetConnectedState(dwflags, 0&)
IsProxyConnection = dwflags And ProxyConnection
End Function

Public Function IsConnected() As Boolean
'Returns true if there is any internet connection.
IsConnected = InternetGetConnectedState(0&, 0&)

End Function

Public Function IsRasInstalled() As Boolean
Dim dwflags As Long
'return True if RAS installed.
Call InternetGetConnectedState(dwflags, 0&)
IsRasInstalled = dwflags And RasInstalled
End Function


Public Function ConnectionTypeMsg() As String
Dim dwflags As Long
Dim msg As String
'Return Internet connection msg.

If InternetGetConnectedState(dwflags, 0&) Then

If dwflags And InternetConnectionIsConfigured Then
msg = msg & "Internet connection is configured." & vbCrLf
End If

If dwflags And LanConnection Then
msg = msg & "Internet connection via a LAN"
End If

If dwflags And ProxyConnection Then
msg = msg & ", and connection is through a proxy server."
Else
msg = msg & "."
End If

If dwflags And ModemConnection Then
msg = msg & "Internet connection via a Modem"
End If

If dwflags And InternetIsOffline Then
msg = msg & "Internet connection is currently offline."
End If

If dwflags And ModemConnectionIsBusy Then
msg = msg & "Modem is busy with a non-Internet connection."
End If

If dwflags And RasInstalled Then
msg = msg & "Remote Access Services are installed on local system."
End If

Else
msg = "You are currently not connected to the internet."

End If

ConnectionTypeMsg = msg

End Function

albalooband
پنج شنبه 20 فروردین 1388, 08:29 صبح
Option Explicit
Public Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
'Internet connection VIA Proxy server.
Public Const ProxyConnection As Long = &H4
'Modem is busy.
Public Const ModemConnectionIsBusy As Long = &H8
'Internet connection is currently Offline
Public Const InternetIsOffline As Long = &H20
'Internet connection is currently configured
Public Const InternetConnectionIsConfigured As Long = &H40
'Internet connection VIA Modem.
Public Const ModemConnection As Long = &H1
'Remote Access Server is installed.
Public Const RasInstalled As Long = &H10
'Internet connection VIA LAN.
Public Const LanConnection As Long = &H2

Public Function IsLanConnection() As Boolean
Dim dwflags As Long
'return True if LAN connection
Call InternetGetConnectedState(dwflags, 0&)
IsLanConnection = dwflags And LanConnection
End Function


Public Function IsModemConnection() As Boolean
Dim dwflags As Long
'return True if modem connection.
Call InternetGetConnectedState(dwflags, 0&)
IsModemConnection = dwflags And ModemConnection
End Function


Public Function IsProxyConnection() As Boolean
Dim dwflags As Long
'return True if connected through a proxy.
Call InternetGetConnectedState(dwflags, 0&)
IsProxyConnection = dwflags And ProxyConnection
End Function

Public Function IsConnected() As Boolean
'Returns true if there is any internet connection.
IsConnected = InternetGetConnectedState(0&, 0&)

End Function

Public Function IsRasInstalled() As Boolean
Dim dwflags As Long
'return True if RAS installed.
Call InternetGetConnectedState(dwflags, 0&)
IsRasInstalled = dwflags And RasInstalled
End Function


Public Function ConnectionTypeMsg() As String
Dim dwflags As Long
Dim msg As String
'Return Internet connection msg.

If InternetGetConnectedState(dwflags, 0&) Then

If dwflags And InternetConnectionIsConfigured Then
msg = msg & "Internet connection is configured." & vbCrLf
End If

If dwflags And LanConnection Then
msg = msg & "Internet connection via a LAN"
End If

If dwflags And ProxyConnection Then
msg = msg & ", and connection is through a proxy server."
Else
msg = msg & "."
End If

If dwflags And ModemConnection Then
msg = msg & "Internet connection via a Modem"
End If

If dwflags And InternetIsOffline Then
msg = msg & "Internet connection is currently offline."
End If

If dwflags And ModemConnectionIsBusy Then
msg = msg & "Modem is busy with a non-Internet connection."
End If

If dwflags And RasInstalled Then
msg = msg & "Remote Access Services are installed on local system."
End If

Else
msg = "You are currently not connected to the internet."

End If

ConnectionTypeMsg = msg

End Function





لطفا بگید کدم کد برای کجاست

Babak.Hassanpour
پنج شنبه 20 فروردین 1388, 08:45 صبح
فکر نمی کنم چیز مبهمی باشه مگر اینکه زبان انگلیسیتون خوب نباشه آخه تقریبا همش اصطلاحات رایج کامپیوتره.به هر حال یه توضیح مختصر میدم



"Internet connection is configured."
شما رو از پیکر بندی شدن اتصال اینترنت مطلع میکنه
"Internet connection via a LAN"
میگه شما از طریق کارت شبکه وصلی
connection is through a proxy server
میگه شما پشت یه پروکسی ( معمولا سرور شبکه لن) مخفی هستی
Internet connection via a Modem
از مودم دیال آپ استفاده می کنی
"Internet connection is currently offline."
تو شبکه هستی ولی اتصال اینترنتی نداری
"Modem is busy with a non-Internet connection."
میگه مودم با یه اتصال غیر اینترنتی درگیره
"Remote Access Services are installed on local system."
سرویس دسترسی راه دور نصبه
"You are currently not connected to the internet."
شما آفلاینی

Babak.Hassanpour
پنج شنبه 20 فروردین 1388, 08:59 صبح
این کد شامل همه نوع اینترنت میشه؟ اگه برنامه تو محیطی که شبکه هست(ولی اینترنت نیست) باشه چطور؟

ممکنه بعضی کد ها تو بعضی توپولوژی های شبکه کارکرد صحیحی نداشته باشه.این جور وقتا میشه از روش های دیگه واسه صحت اتصال اینترنتی استفاده کرد.مثلا پینگ کردن یه سایت که معمولا آپ تایم بالا و سرعت پاسخ سریعی داشته باشه مثل GOOGLE
به این میگن کلک رشتی .خودمونیم ها رشتی بودنم یه جاهایی بدرد میخوره :قهقهه: :قهقهه: :قهقهه:

albalooband
پنج شنبه 20 فروردین 1388, 10:30 صبح
ممکنه بعضی کد ها تو بعضی توپولوژی های شبکه کارکرد صحیحی نداشته باشه.این جور وقتا میشه از روش های دیگه واسه صحت اتصال اینترنتی استفاده کرد.مثلا پینگ کردن یه سایت که معمولا آپ تایم بالا و سرعت پاسخ سریعی داشته باشه مثل GOOGLE
به این میگن کلک رشتی .خودمونیم ها رشتی بودنم یه جاهایی بدرد میخوره :قهقهه: :قهقهه: :قهقهه:
ممنون از کدتون. منم یه چیزی تو همین مایه ها میخوام
ولی ساده تر(تا بنونم درکش کنم)
مثلا یک سایتی رو چکی چیزی کنه.اگه جواب + بود اجازه دسترسی به بعضی قسمت های برنامه رو بده.
راستی کد بالا هم ارور داد.

منم بچه گیلانم :لبخند:

Babak.Hassanpour
پنج شنبه 20 فروردین 1388, 10:39 صبح
راستی کد بالا هم ارور داد.



میشه بگید ارورش چی بود؟چون قبل از آپلود تست کردم مشکلی نداشت

http://barnamenevis.org/forum/attachment.php?attachmentid=29809&stc=1&d=1239259744



منم بچه گیلانم :لبخند:


تی جانه ره بیمیرم ، خوشحاله بوستم :بوس:

albalooband
پنج شنبه 20 فروردین 1388, 13:51 عصر
الان من از این چطور تو برنامم استفاهده کنم؟
میخوام اگه اینترنت وصل باشه 2 تا دکمه enable=true بشه
کدو کد رو کجا باید بزارم

Babak.Hassanpour
پنج شنبه 20 فروردین 1388, 13:56 عصر
الان من از این چطور تو برنامم استفاهده کنم؟
میخوام اگه اینترنت وصل باشه 2 تا دکمه enable=true بشه
کدو کد رو کجا باید بزارم
اینجا ها



"Internet connection via a LAN"
میگه شما از طریق کارت شبکه وصلی
connection is through a proxy server
میگه شما پشت یه پروکسی ( معمولا سرور شبکه لن) مخفی هستی
Internet connection via a Modem
از مودم دیال آپ استفاده می کنی