Solved

Capture Network disconnect message

Posted on 2006-11-13
4
840 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

9 Experts available now in Live!

Get 1:1 Help Now