Recent

Author Topic: [Solved] Detecting new Network Connection setup !  (Read 829 times)

loaded

  • Hero Member
  • *****
  • Posts: 824
[Solved] Detecting new Network Connection setup !
« on: August 11, 2022, 01:11:54 pm »
Hi All,
Is there a message in the windows operating system that we can catch when a new network connection is established, to detect it?
Or do we have to manually control it ourselves in the timer ?
« Last Edit: August 11, 2022, 03:21:44 pm by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

440bx

  • Hero Member
  • *****
  • Posts: 3945
Re: Detecting new Network Connection setup !
« Reply #1 on: August 11, 2022, 01:34:32 pm »
Is there a message in the windows operating system that we can catch when a new network connection is established, to detect it?
TTBOMK, there is no such message.

Or do we have to manually control it ourselves in the timer ?
Yes, I believe that is the only way. (unless the program itself is creating a new connection.)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: Detecting new Network Connection setup !
« Reply #2 on: August 11, 2022, 02:19:57 pm »
As 440bx mentioned, there isn't a simple message.

Next best is to look at Receiving Notification of Network EventsNotifyAddrChange will notify you when something in the network setup has changed.  Then use GetIPAddrTable to figure out what changed.  Not simple, but at least you only have to check for a new IP address when a network change notification is received.

loaded

  • Hero Member
  • *****
  • Posts: 824
Re: Detecting new Network Connection setup !
« Reply #3 on: August 11, 2022, 03:01:58 pm »
Thank you very much for your answers 440bx and ccrause
Good to know NotifyAddrChange. I think I can get out of this point and reach the point I want. Respects.


When I went to point NotifyAddrChange I found an earlier post. For now this solution solved my problem.
https://forum.lazarus.freepascal.org/index.php/topic,49350.msg357495.html#msg357495
« Last Edit: August 11, 2022, 03:21:13 pm by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

 

TinyPortal © 2005-2018