Results 1 to 6 of 6

Thread: Network check

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    Network check

    hey guys i need the program to check whether the computer is connected to internet or not


    with the warning message "not connected' if not connected

    PLz help me fast

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Network check

    You could try pinging the local computer's default gateway, and then ping the local ISP's dns servers. If you can ping the DNS servers, chances are you're connected.
    You can check if you're on the local network by using this code:

    Code:
    My.Computer.Network.IsAvailable()
    You can use the methods in My.Computer.Network to figure out if you're connected or not
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    Angry Re: Network check

    Common guys help me out


    i know how to check whther the computer is connected net or not

    but i need to know how to make exe to check the computer is connected to internet or not

  4. #4
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Network check

    you should use Winsock, but here is an API version

    VB Code:
    1. Option Explicit
    2.  
    3. Private Const FLAG_ICC_FORCE_CONNECTION = &H1
    4. Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" _
    5. (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
    6.  
    7. Private Const sURL As String = "http://www.mytesturl.com"
    8.  
    9. Private Function CheckInternet() As Boolean
    10.     If InternetCheckConnection(sURL, FLAG_ICC_FORCE_CONNECTION, 0&) Then
    11.         CheckInternet = True
    12.     End If
    13. End Function
    14.  
    15. Private Sub Command1_Click()
    16.     MsgBox CheckInternet
    17. End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    6

    thnks fo sugestion Network check

    frens thanks for all of u for sending me the solutions

    happy frenship week

  6. #6
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Network check

    no prob, remember to change the URL to a valid one so it works..

    Tip, if you were to use Winsock, then use the Winsock Error and Connect Events to set a Boolean, it will not hang like the API does temporarily when it cant connect .. but it will require more code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width