Solved

network check

Posted on 2004-03-29
6
165 Views
Last Modified: 2013-11-13
HI experts...
  I am trying to creating an application in visual basic such that if the communication link (LAN Cable) between 2 pc's is not available(broken/removed) then it must trigger a message. I think I might have to use windows API for that but I am not too sure. Can you all please help me? I am really looking forward to your comments.
0
Comment
Question by:Daran_M
  • 2
6 Comments
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10709572
U can ping the Computer .. and when u dont get an reply trigger an event...

here is a simple ping code for VB ( Thanx to PLG)

Public Function Ping(sAddress As String, _
                     sDataToSend As String, _
                     ECHO As ICMP_ECHO_REPLY) As Long

   Dim hPort As Long
   Dim dwAddress As Long
   
  'convert the address into a long representation
   dwAddress = inet_addr(sAddress)
   
  'if dwAddress is valid
   If dwAddress <> INADDR_NONE Then
   
     'open a port
      hPort = IcmpCreateFile()
     
     'and if successful,
      If hPort Then
     
        'ping it.
         Call IcmpSendEcho(hPort, _
                           dwAddress, _
                           sDataToSend, _
                           Len(sDataToSend), _
                           0, _
                           ECHO, _
                           Len(ECHO), _
                           glngPingTime)

        'return the status as ping success
         Ping = ECHO.status

        'close the port handle
         Call IcmpCloseHandle(hPort)
     
      End If  'If hPort
     
   Else:
   
        'the address format was probably invalid
         Ping = INADDR_NONE
         
   End If
 
End Function
0
 
LVL 1

Expert Comment

by:developer007
ID: 10709833
Yeh..

 Some times the connection is proper and ping may not happen also..


   
0
 

Author Comment

by:Daran_M
ID: 10714446
HI experts,
         thanks for the reply. Isn’t there any API function that can be used to achieve this? thanks once again for the reply.
0
 
LVL 19

Accepted Solution

by:
Melih SARICA earned 50 total points
ID: 10714528
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now