October 2009
M T W T F S S
    Nov »
 1234
567891011
12131415161718
19202122232425
262728293031  

Archives

Categories

  • [+]ASP.NET (7) 
  • [+]C# (87) 
  • [+]C++ (13) 
  • [+]Delphi (20) 
  • [+]JavaScript (24) 
  • [+]Regular Expressions (7) 
  • [+]SQL (13) 
  • [—]VB (100) 
  • [+]VB.NET (4) 

Online

Users: 6 Guests, 1 Bot
  • Loading...


    Loading...

    Login






    Register | Lost password?

    Register





    A password will be mailed to you.
    Log in | Lost password?

    Retrieve password





    A confirmation mail will be sent to your e-mail address.
    Log in | Register
  • Determine if a computer is connected to the Internet

    ' ----------------------------
    ' Constants & API Declarations
    ' ----------------------------
    
    Public Declare Function RasEnumConnections Lib "RasApi32.dll" Alias "RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Long
    Public Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias "RasGetConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As Long
    
    Public Const RAS95_MaxEntryName = 256
    Public Const RAS95_MaxDeviceType = 16
    Public Const RAS95_MaxDeviceName = 32
    
    Public Type RASCONN95
        dwSize As Long
        hRasCon As Long
        szEntryName(RAS95_MaxEntryName) As Byte
        szDeviceType(RAS95_MaxDeviceType) As Byte
        szDeviceName(RAS95_MaxDeviceName) As Byte
    End Type
    '
    Public Type RASCONNSTATUS95
        dwSize As Long
        RasConnState As Long
        dwError As Long
        szDeviceType(RAS95_MaxDeviceType) As Byte
        szDeviceName(RAS95_MaxDeviceName) As Byte
    End Type
    
    ' --------
    ' Code
    ' --------
    
    'A call to the function IsConnected returns true if the computer has established a connection to the internet.
    
    Public Function IsConnected() As Boolean
        Dim TRasCon(255) As RASCONN95
        Dim lg As Long
        Dim lpcon As Long
        Dim RetVal As Long
        Dim Tstatus As RASCONNSTATUS95
    
        TRasCon(0).dwSize = 412
        lg = 256 * TRasCon(0).dwSize
    
        RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)
        If RetVal <> 0 Then
            MsgBox "Error!"
            Exit Function
        End If
    
        Tstatus.dwSize = 160
        RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
        If Tstatus.RasConnState = &H2000 Then
           IsConnected = True
        Else
            IsConnected = False
        End If
    End Function
    
    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    Leave a Reply

     

     

     

    You can use these HTML tags

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">

    Spam Protection by WP-SpamFree Plugin