Arsip: Mo coba bwat program sederhana ......

more 19 years ago
cyber_hecker
program tutorial 6 - get windows, system, program files directory and execute program
kode lengkap :

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
RadioGroup1: TRadioGroup;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Registry;
function GetRegistryData(RootKey: HKEY; Key, Value: string): variant;
var
Reg: TRegistry;
RegDataType: TRegDataType;
DataSize, Len: integer;
s: string;
label cantread;
begin
Reg := nil;
try
Reg := TRegistry.Create(KEY_QUERY_VALUE);
Reg.RootKey := RootKey;
if Reg.OpenKeyReadOnly(Key) then begin
try
RegDataType := Reg.GetDataType(Value);
if (RegDataType = rdString) or
(RegDataType = rdExpandString) then
Result := Reg.ReadString(Value)
else if RegDataType = rdInteger then
Result := Reg.ReadInteger(Value)
else if RegDataType = rdBinary then begin
DataSize := Reg.GetDataSize(Value);
if DataSize = -1 then goto cantread;
SetLength(s, DataSize);
Len := Reg.ReadBinaryData(Value, PChar(s)^, DataSize);
if Len <> DataSize then goto cantread;
Result := s;
end else
cantread:
raise Exception.Create(SysErrorMessage(ERROR_CANTREAD));
except
s := ''; // Deallocates memory if allocated
Reg.CloseKey;
raise;
end;
Reg.CloseKey;
end else
raise Exception.Create(SysErrorMessage(GetLastError));
except
Reg.Free;
raise;
end;
Reg.Free;
end;
function GetProgramFilesDir: TFileName;
begin
Result := GetRegistryData(HKEY_LOCAL_MACHINE,
'\Software\Microsoft\Windows\CurrentVersion',
'ProgramFilesDir'); // or 'ProgramFilesPath'
end;
function GetWindowsDir: TFileName;
var
WinDir: array [0..MAX_PATH-1] of char;
begin
SetString(Result, WinDir, GetWindowsDirectory(WinDir, MAX_PATH));
if Result = '' then
raise Exception.Create(SysErrorMessage(GetLastError));
end;
function GetSystemDir: TFileName;
var
SysDir: array [0..MAX_PATH-1] of char;
begin
SetString(Result, SysDir, GetSystemDirectory(SysDir, MAX_PATH));
if Result = '' then
raise Exception.Create(SysErrorMessage(GetLastError));
end;
procedure TForm1.Button1Click(Sender: TObject);
const sProgram : Array [0..10] of String
= ('excel.exe', 'frontpg.exe', 'winword.exe',
'powerpnt.exe', 'outlook.exe', 'msaccess.exe',
'notepad.exe', 'regedit.exe','cliconfg.exe',
'calc.exe', 'freecell.exe');
begin
if RadioGroup1.ItemIndex in [0..5] then
WinExec(
PChar(GetProgramFilesDir+'\Microsoft Office\Office'+sProgram[RadioGroup1.ItemIndex]),
SW_NORMAL)
else
if RadioGroup1.ItemIndex in [6..7] then
WinExec(
PChar(GetWindowsDir+''+sProgram[RadioGroup1.ItemIndex]),
SW_NORMAL)
else
if RadioGroup1.ItemIndex in [8..10] then
WinExec(
PChar(GetSystemDir+''+sProgram[RadioGroup1.ItemIndex]),
SW_NORMAL)
else
ShowMessage('Bego Loe, Kok Gak Dipilih Optionnya !');
end;
end.

more 19 years ago
LuriDarmawan
kayanya mending CH buat/submit ke artikel saja deh..
http://pascal-id.org/dpr/Submit_News.pas

more 19 years ago
EkoIndri
:D
untung aq lom sempet tambahkan.......
ok, masuk artikel ajalah.......
@luri
tapi postingnya nggak nambah............. wakakakakakak
kabooooooooor.....

more 19 years ago
cyber_hecker
pengennya seh masuk in artikel. tapi di artikel BBCode-nya gak bisa seh. gue rada bingung kalo masuk in gambar pake kode html. boss.. di enabled dunk BBCode buat artikel... :D

more 19 years ago
danzfx
@LuriDarmawan: kayanya mending CH buat/submit ke artikel saja deh.. http://pascal-id.org/dpr/Submit_News.pasCH apatuh?? :? thankz :)

more 19 years ago
cyber_hecker
OOT: iya neh... mosok belon kenal ama selebrites yang cakep, baik, ramah tamah, keren, sabar, penyayang, setia, rendah diri, pemalu yang satu ini... wakakakakakak 


more 19 years ago
EkoIndri
di iya-in aja biar seneng..........
ntar klo ngambek g berani masuk ni forum lagi lho.........

more 19 years ago
imunk
selain itu gak mau ngejawab kalo ditanya lagi.....
bisa ngejawab kalo kita bs ngerayu dia, kayak saysnsay......
dia tuh paling jago dalam rayu merayu...........
mana nih dia kok gak nongol ya....

more 19 years ago
cyber_hecker
OOT: kekekeke... bukannya gak mau njawab, tapi kalo emang gue gak bisa, gue gak mau njawab. dari pada mberi jawaban yang gak nyambung :P, lebih baik diem... dan kalo gue bisa njawab, pasti ku jawab :D
more ...
- Pages:
- 1
- 2
reply |
Report Obsolete
AI Forward

🚀 We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now:
https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 5 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 12 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 12 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 12 years ago
Random Topic
- Ambil Cash Drawer saja dari Mesin Cash Register
by khairul in Network, Files, I/O & System more 16 years ago - Tips koneksi Database yang handal
by DelphiExpert in Hal umum tentang Pascal Indonesia more 19 years ago - autolock
by marvel in Hal umum tentang Pascal Indonesia more 19 years ago - Tampilan currency di Tedit
by juandon in Tip n Trik Pemrograman more 16 years ago - Uppercase!
by ZeAL in MySQL more 19 years ago - Membuka file dari Delphi tanpa tahu itu file jenis apa...
by dermawan in MySQL more 18 years ago - Konversi antara 2 DateTime ke detik
by DelphiExpert in Tip n Trik Pemrograman more 19 years ago - Delphi vs Ms.Access
by wiedhodho in Hal umum tentang Pascal Indonesia more 18 years ago - Program akuntansi delphi
by cylock in Tip n Trik Pemrograman more 15 years ago - Code delphi untuk interface ke led display
by sp1d3r_n3tz in Enginering more 17 years ago