How does delphi ping the computer name or IP address?

Source: Internet
Author: User
How to ping the computer name or IP address in Delphi? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiNetwork/html/delphi_20061201140126219.html
How does delphi ping the computer name or IP address ???

Indy idicmp

Function tmainform. Ping (var url: string): Boolean; var
Aidicmpclient: tidicmpclient;
Begin
Aidicmpclient: = tidicmpclient. Create (NiL );
Aidicmpclient. receivetimeout: = 500;
Aidicmpclient. HOST: = URL;
Try
Aidicmpclient. Ping ();
Except
Result: = false;
End;
If (aidicmpclient. replystatus. fromipaddress <> '0. 0.0.0 ')
And (aidicmpclient. replystatus. fromipaddress <> '') then
Result: = true
Else
Result: = false;
Aidicmpclient. Free;
End;


Can I ping the IP address but cannot ping the computer name?
Why

Ping in "cmd" to see
In addition, if the operating system is XP, sometimes the machine name cannot be pinged.

Add one in the hosts file: (XP: c: \ windows \ system32 \ drivers \ etc directory)

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample hosts file used by Microsoft TCP/IP for Windows.
#
# This file contains the Mappings of IP addresses to host names. Each
# Entry shoshould be kept on an individual line. The IP address shold
# Be placed in the first column followed by the corresponding host name.
# The IP address and the host name shocould be separated by at least one
# Space.
#
# Additionally, comments (such as these) may be inserted on individual
# Lines or following the machine name denoted by a' # 'symbol.
#
# For example:
#
#102.54.94.97 rhino.acme.com # source server
#38.25.63.10 x.acme.com # X client host

127.0.0.1 localhost
# Input your IP address and host in the following format
200.211.110.20.sanmaotuo

If I add what I said upstairs, it will certainly work.
But there are so many ugly computers in the LAN. I can't change all my hosts files.
It seems to be a DNS problem.

I originally wanted to use the API to interpret the name as IP, but if it is not included in hosts. It cannot be parsed.
Is there any other way ..
Experts, please help me

Pass

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.