untuk bikin program (pake delphi) yang menjalankan program lain caranya ga susah, singkat dan padat kok
langkah2nya:

  • siap2 dulu, buka delphi, ntar muncul form1.
  • sebelum mulai, tekan dulu F12 untuk berpindah ke jendela coding. pada bagian unit, tambahkan unit ShellAPI
  • tambahkan object Edit yang ada pada komponen Standard
  • tambahkan object Button, captionnya beri nama Browse…
  • tambahkan lagi object Button, captionnya beri nama Run
  • tambahkan object OpenDialog yang ada di komponen Dialogs
  • skarang, double klik Button Browse…, ntar muncul procedure TForm1.ButtonBrowseClick(Sender: TObject); pada body procedure tsb tambahkan sintaks berikut.
if OpenDialog1.Execute then
 Edit1.Text := OpenDialog1.FileName;
  • berikutnya, double klik Button Run, ntar muncul procedure TForm1.ButtonRunClick(Sender: TObject); pada body procedure tsb tambahkan sintaks berikut.
if ShellExecute(0, 'open', PChar(Edit1.Text), '', '',SW_SHOWNORMAL) <= 32 then
 MessageDlg('Gagal menjalankan program',mtError,[mbOK],0);
  • skarang pilih object OpenDialog, pada object inspector, pilih property Filter, double klik value-nya yang masih kosong, ntar muncul Filter Editor-nya
  • tambahkan filter, Filter Name-nya isi dengan Executable File (*.exe), lalu Filternya harus diisi dengan *.exe

udah d, cuma segitu aja, semoga membantu.

Mengapa kita perlu mengecek apakah nilai kembalian fungsi shellExecute? Karena fungsi ini akan mengembalikan nilai kurang dari atau sama dengan 32 bila gagal dijalankan. Berikut ini list error pemanggilan fungsi shellExecute:

0 = The operating system is out of memory or resources.
2 = The specified file was not found
3 = The specified path was not found.
5 = Windows 95 only: The operating system denied access to the specified file
8 = Windows 95 only: There was not enough memory to complete the operation.
10 = Wrong Windows version
11 = The .EXE file is invalid (non-Win32 .EXE or error in .EXE image)
12 = Application was designed for a different operating system
13 = Application was designed for MS-DOS 4.0
15 = Attempt to load a real-mode program
16 = Attempt to load a second instance of an application with non-readonly data segments.
19 = Attempt to load a compressed application file.
20 = Dynamic-link library (DLL) file failure.
26 = A sharing violation occurred.
27 = The filename association is incomplete or invalid.
28 = The DDE transaction could not be completed because the request timed out.
29 = The DDE transaction failed.
30 = The DDE transaction could not be completed because other DDE transactions were being processed.
31 = There is no application associated with the given filename extension.
32 = Windows 95 only: The specified dynamic-link library was not found.