The code that works without error in delphi 7 may cause an error in lazarus.
Can you be more specific? What is the actual error? Is it a compile-time error, or a run-time error?
If run-time, then is your app running with admin rights?
TIdICMPClient uses a RAW socket to implement ICMP manually, and using a RAW socket requires admin rights on most modern platforms.
Which version of Indy are you using in Lazarus? Delphi 7 is VERY OLD, which version of Indy were you using in it at the time? Were you using the version that came bundled with it? If so, that would be a VERY OLD version of Indy, a LOT has changed in Indy over the years.
However, the code you have shown
should work in the latest version of Indy.