Mengecek IP Address


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
function LocalIP: string;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

uses
Winsock;

{$R *.dfm}

function
TForm1.LocalIP : string;
type
TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
I : Integer;
GInitData : TWSADATA;
begin
WSAStartup($101, GInitData);
Result := ”;
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then
begin
Exit;
end;
pptr := PaPInAddr(Phe^.h_addr_list);
I := 0;
while pptr^[I] <> nil do
begin
result:=StrPas(inet_ntoa(pptr^[I]^));
Inc(I);
end;
WSACleanup;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text := LocalIP;
end;

end.

TransCODE Software

Record Yang Ditemukan Tampil Teratas


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, Db, DBTables, StdCtrls, Grids, DBGrids;

type
TForm1 = class(TForm)
Panel1: TPanel;
DBGrid1: TDBGrid;
Edit1: TEdit;
DataSource1: TDataSource;
Table1: TTable;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

type

TGridCracker = class(TCustomGrid);

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var

Distance : integer;

begin
Table1.Locate(‘CustNo’,Edit1.Text,[]);
Distance := Table1.MoveBy(TGridCracker(DBGrid1).VisibleRowCount-1);
Table1.MoveBy(-Distance);
end;

end.

TransCODE Software