Mengecek Tipe Partisi pada Hardisk


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)
btn1: TButton;
lbl1: TLabel;
lbl2: TLabel;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function GetHardDiskPartitionType(const DriveLetter: Char): string;
var
NotUsed: DWORD;
VolumeFlags: DWORD;
VolumeInfo: array[0..MAX_PATH] of Char;
VolumeSerialNumber: DWORD;
PartitionType: array[0..32] of Char;
begin
GetVolumeInformation(PChar(DriveLetter + ‘:\’),
nil, SizeOf(VolumeInfo), @VolumeSerialNumber, NotUsed,
VolumeFlags, PartitionType, 32);
Result := PartitionType;
end;


procedure
TForm1.btn1Click(Sender: TObject);
begin

lbl1.Caption:=’Drive C : Tipe Partsi ‘+ GetHardDiskPartitionType(‘c’);
lbl2.Caption:=’Drive D : Tipe Partsi ‘+ GetHardDiskPartitionType(‘d’);
end;

end.

TransCODE Software



Teks Berjalan Pada Form Caption


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

interface

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

type
TForm1 = class(TForm)
Timer1: TTimer;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Old_Title : String;

implementation

{$R *.DFM}

procedure
TForm1.FormCreate(Sender: TObject);
begin
Application.Title := ‘Selamat Belajar Delphi ‘;
Old_Title := Application.Title;
end;

procedure
TForm1.Timer1Timer(Sender: TObject);
var
temp : string;
begin
Temp := Application.Title;
Temp := Temp+Temp[1];
Temp := Copy(Temp,2,length(temp)-1);
Application.Title := temp;
Form1.Caption:=temp;
end;

procedure
TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled := NOT Timer1.Enabled;
if Timer1.Enabled = False then
begin
Application.Title := Old_Title;
Form1.Caption := Old_Title;
end;
end;

end.

TransCODE Software



Mengecek Nama Host


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 IPAddrToName(IPAddr: String): String;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

uses winsock;

{$R *.dfm}

function TForm1.IPAddrToName(IPAddr: string): string;
var
SockAddrIn: TSockAddrIn;
HostEnt: PHostEnt;
WSAData: TWSAData;
begin
WSAStartup($101, WSAData);
try
SockAddrIn.sin_addr.s_addr := inet_addr(PChar(IPAddr));
HostEnt := GetHostByAddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET);
if Assigned(HostEnt) then
Result := StrPas(Hostent^.h_name)
else
Result := ”;
finally
WSACleanup;
end;
end;

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

end.

TransCODE Software

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