Solved

network check

Posted on 2004-03-29
6
168 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 84
base64 decode encode 12 119
Hide vba in gp 7 82
Please help| Getting the syntax error in below query. 2 45
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
A short article about a problem I had getting the GPS LocationListener working.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

911 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

21 Experts available now in Live!

Get 1:1 Help Now