Delphi 7 fast Get native IP address

Source: Internet
Author: User

Friends in the use of Delphi programming, often encounter the need to get their own IP address in the program. In previous versions, you could have done this by writing a piece of code or a function. But with Delphi 7, the job can be simplified. This functionality can be easily achieved by using a control with just one sentence of code.

Create a new Project1, add control statusbar1 (Win32 page) and control IdIPWatch1 (Indy misc page) to Form1. Then set the control properties: Add 0-tstatuspanel and 1-tstatuspanel two items to the STATUSBAR1 panels, and IdIPWatch1 's Historyenabled property to False.

Write code: Add the following code to Tform1.formcreate (sender:tobject):

StatusBar1. PANELS[1]. Text:=idipwatch1.localip;

Ok! Press the F9 function key, run the program, look at the bottom of the window is not the status bar has shown the IP address of this machine?

Tip: If IdIPWatch1 's Historyenabled property is set to True, a file (the value set by the Historyfilename property) is automatically generated when the program exits, recording the current IP address.

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.