Selamat Datang !

Selamat Datang di Yus Waroeng Software ! Saya ucapkan terima kasih anda sudah masuk ke blog kami, dimana anda dapat mencari informasi Software Aplikasi yang anda butuhkan dan berbagi ilmu pemograman.
Cari Artikel

Saturday, March 29, 2008

Delphi Window API Tutorial

Yus Waroeng Software’s Delphi Tutorial

Melihat Default Language Windows

procedure TForm1.Button1Click(Sender: TObject);
var
Ident: Integer;
MyLang: PChar;
const
Size: Integer = 250;
begin
GetMem(MyLang, Size);
Ident:=GetSystemDefaultLangID;
VerLanguageName(Ident, MyLang, Size);
Label1.Caption:=StrPas(MyLang);
FreeMem(MyLang);
end;

Melihat Informasi Memory Windows

procedure TForm1.Button1Click(Sender: TObject);
var
MyStatus: TMemoryStatus;
begin
MyStatus.dwLength:=SizeOf(MyStatus);
GlobalmemoryStatus(MyStatus);
with Memo1.Lines do
begin
Add(FloatToStr(
MyStatus.dwMemoryLoad)+'% memory in use');
Add(FloatToStr(
MyStatus.dwTotalPhys/1024)+' Kb of physical memory');
Add(FloatToStr(
MyStatus.dwAvailPhys/1024)+
' Kb of available physical memory');
Add(FloatToStr(
MyStatus.dwTotalPageFile/1024)+
' Kb that can be stored in the paging file');
Add(FloatToStr(
MyStatus.dwAvailPageFile/1024)+
' Kb available in the paging file');
end;
end;

Melihat Pesan Error terakhir

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(SysErrorMessage(GetLastError));
end;
sumber :http://www.greatis.com

Menacri Drive Booting

uses Registry;
...
procedure TForm1.Button1Click(Sender: TObject);
begin
with TRegistry.Create do
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey(
'SoftwareMicrosoftWindowsCurrentVersionSetup',
False) then
try
Edit1.Text:=ReadString('BootDir');
except
MessageDlg('Tidak Bisa di Handel',mtError,[mbOk],0);
end
else
MessageDlg('Registry error dibaca',mtError,[mbOk],0);
CloseKey;
end;
end;

Mengubah tampilan resolusi monitor

procedure TForm1.Button1Click(Sender: TObject);
var
MyMode: TDeviceModeA;
begin
MyMode.dmSize:=Sizeof(MyMode);
MyMode.dmFields:=DM_PELSWIDTH and DM_PELSWIDTH;
MyMode.dmPelsWidth:=StrToInt(Edit1.Text);
MyMode.dmPelsHeight:=StrToInt(Edit2.Text);
ChangeDisplaySettings(MyMode, 0);
end;

Mengaktifkan Screensaver

procedure TForm1.Button1Click(Sender: TObject);
begin
DefWindowProc(Form1.Handle,WM_SYSCOMMAND,SC_SCREENSAVE,0);
end;

Cek CD-Room (eject,insert)

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

type
TForm1 = class(TForm)
procedure CDROM_Notification(var msg: TMessage);
message WM_DEVICECHANGE;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

const
CD_OUTPUT = $8004;
CD_INPUT = $8000;

procedure TForm1.CDROM_Notification(var msg: TMessage);
begin
if msg.wParam = CD_INPUT then
ShowMessage(’There is a new CD.’)
else if msg.wParam = CD_OUTPUT then
ShowMessage(’CD was ejected.’);
end;

end.

Klik Windows Anda ( Minimize, Run, Date Time, IE Options …)

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ComObj;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
procedure Shell(sMethod: Integer);
end;

var
Form1: TForm1;
oShell: OleVariant;

implementation

{$R *.DFM}

procedure TForm1.Shell(sMethod: Integer);
begin
case sMethod of
0:
{Minimizes all windows on the desktop}
begin
oShell.MinimizeAll;
Button1.Tag := Button1.Tag + 1;
end;
1:
{Displays the Run dialog}
begin
oShell.FileRun;
Button1.Tag := Button1.Tag + 1;
end;
2:
{Displays the Shut Down Windows dialog}
begin
oShell.ShutdownWindows;
Button1.Tag := Button1.Tag + 1;
end;
3:
{Displays the Find dialog}
begin
oShell.FindFiles;
Button1.Tag := Button1.Tag + 1;
end;
4:
{ Displays the Date / Time dialog}
begin
oShell.SetTime;
Button1.Tag := Button1.Tag + 1;
end;
5:
{Displays the Internet Properties dialog}
begin
oShell.ControlPanelItem(’INETCPL.cpl’);
Button1.Tag := Button1.Tag + 1;
end;
6:
{Enables user to select folder from Program Files}
begin
oShell.BrowseForFolder(0, ‘My Programs’, 0, ‘C:\Program Files’);
Button1.Tag := Button1.Tag + 1;
end;
7:
{Displays the Taskbar Properties dialog}
begin
oShell.TrayProperties;
Button1.Tag := Button1.Tag + 1;
end;
8:
{Un-Minimizes all windows on the desktop}
begin
oShell.UndoMinimizeAll;
Button1.Tag := 0;
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
oShell := CreateOleObject(’Shell.Application’);
Shell(Button1.Tag);
oShell := VarNull;
end;

end.

0 comments:

Post a Comment

Leave Your Comment Here!

Komentar Terbaru