Community discussion forum

Check for a network connection routine in VB

  • 5 months ago

    Hi all,

    New to this site...

    I was wondering if any of you lovely people out there know how to check, in a VB routine, if a PC has/dropped a network connection.

    I have an existing routine which will open a randomly selected table as a test of a network connection but there must be a better way of doing it.

    Thanks guys

    Sukie Angel

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 4 months ago

    here is a quick way to see if a drive latter is still valid.  If the drive letter of the network is missing then the connection has been lost.

    you need to declare this api routine 

    Private Declare Function GetLogicalDriveStrings Lib "kernel32" _
         Alias "GetLogicalDriveStringsA" _
        (ByVal nBufferLength As Long, _
         ByVal lpBuffer As String) As Long

     then in your code you can make this comparison

    IF

     

  • 4 months ago

    here is a quick way to see if a drive latter is still valid.  If the drive letter of the network is missing then the connection has been lost.

    you need to declare this api routine 

    Private Declare Function GetLogicalDriveStrings Lib "kernel32" _
         Alias "GetLogicalDriveStringsA" _
        (ByVal nBufferLength As Long, _
         ByVal lpBuffer As String) As Long

     then in your code you can make this comparison

    IF NOT

  • 4 months ago

    here is a quick way to see if a drive latter is still valid.  If the drive letter of the network is missing then the connection has been lost.

    you need to declare this api routine 

    Private Declare Function GetLogicalDriveStrings Lib "kernel32" _
         Alias "GetLogicalDriveStringsA" _
        (ByVal nBufferLength As Long, _
         ByVal lpBuffer As String) As Long

     then in your code you can make this comparison

    sBuff = space(26 * 4)

    IF NOT Instr(1, GetLogicalDriveStrings(len(sBuff),SBuff), sDriveLetterYouWantToTest) THEN

        '* Drive is not connected

    end if

    Hope this was what you are looking for

     

Post a reply

Enter your message below

Sign in or Join us (it's free).