Solved

Capture Network disconnect message

Posted on 2006-11-13
4
850 Views
Last Modified: 2012-08-13
Hi Experts,

I need to capture network disconnection event (network cable unplugged). What windows message is responsible for that event?

Sincerely,
odissey1
0
Comment
Question by:odissey1
4 Comments
 
LVL 2

Author Comment

by:odissey1
ID: 17935188
Hi Experts,

Sorry, again. Just to make my problem clear, I am looking for the fastest method to detect that connection is not awailable. The problem is that I am saving data on the networked drive and Application deadlocks if network is suddenly disconnected. For example procedure

if  DirectoryExists('\\remote_computer\some_folder') then...

hangs up my application as well (no exception posted). Seems like WinXP keeps thinking for some time that it is still connected and tries to access a remote folder...

Regards,
odissey1
0
 
LVL 10

Expert Comment

by:wildzero
ID: 17935516
Not sure if it would be the fastest way, but perhaps a ping function to check?

ie

If ConnectionExists = true then
  //do something
else
  //connection lost


Function ConnectionExists : boolean;
Begin
  Try
    Ping Computer, if ping completes then
     Result := true
   else
     Result := false
  except
    Result := false;
  end;
end;

Not sure how well that'd work though.

0
 
LVL 9

Accepted Solution

by:
sun4sunday earned 150 total points
ID: 17935624
how to check whether you are connected to the Internet
http://delphi.about.com/cs/adptips2000/a/bltip1100_4.htm

Also check this PAQ http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21237093.html  from Russel

Other way is You can do that with try catch event.When you try to connect to the network and the connection not exists it will throw the error. Capture the right error and and show the user.

sun4sunday
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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

895 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

13 Experts available now in Live!

Get 1:1 Help Now