Getting Notified Regarding Internet Connections

Environment: Win95, Win98, WinME, WinNT, Win2K, WinXP

I have been looking for some time how to get notified when the user connects to Internet just as MSN or Yahoo Messenger starts the login procedure, as soon as the user connects to Internet. At CodeGuru and other discussion forums, the way people suggested was more of a work-around like pinging a server or IP address after some time interval.

There is a Win32 API, RasConnectionNotification, that I guess applications such as MSN and Yahoo Messenger use to get notified. To use this API, we first need to create an Event Object, using CreateEvent; then we pass the EvenObject created by CreateEvent to RasConnectionNotification (to be signaled by System when Ras Connection is made), and then we wait for the Ras Connection Event to happen using the Wait Function WaitForSingleObject.

Downloads

Download demo project – 4 Kb

Download source – 33 Kb

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read