unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Winsock;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Function GetIPAddress():String;
type
pu_long = ^u_long;
var
varTWSAData : TWSAData;
varPHostEnt : PHostEnt;
varTInAddr : TInAddr;
// sypoh namebuf : Array[0..255] of char;
namebuf: array [0..63] of Ansichar;
begin
If WSAStartup($101,varTWSAData) <> 0 Then
Result := 'No. IP Address'
Else Begin
gethostname(namebuf,sizeof(namebuf));
varPHostEnt := gethostbyname(namebuf);
varTInAddr.S_addr := u_long(pu_long(varPHostEnt^.h_addr_list^)^);
Result := 'IP Address: '+inet_ntoa(varTInAddr);
End;
WSACleanup;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption := GetIPAddress;
end;
end.
Wednesday, 11 April 2018
[vcl worked]Getting local IP address in Delphi
Subscribe to:
Post Comments (Atom)
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required.
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required. h...
-
Grows your business with zomok online ordering platform. Zero commission. Suitable for restaurants, kopitiam, food, groceries, pet supplie...
-
Complete TFTP Server example, using Indy components There are not many good TFTP server examples out there, so I wrote this example of...
程序员的java编程实例
ReplyDelete使用java语言继续语句示例