Author: Jonas Bilinkevicius How to call Windows system dialogs from code Answer: 1 { ... } 2 3 uses 4 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 5 StdCtrls, ComObj; 6 7 type 8 TForm1 = class(TForm) 9 Button1: TButton; 10 procedure Button1Click(Sender: TObject); 11 private 12 { Private declarations } 13 public 14 { Public declarations } 15 procedure Shell(sMethod: Integer); 16 end; 17 18 var 19 Form1: TForm1; 20 oShell: OleVariant; 21 22 implementation 23 24 {$R *.DFM} 25 26 procedure TForm1.Shell(sMethod: Integer); 27 begin 28 case sMethod of 29 0: {Minimizes all windows on the desktop} 30 begin 31 oShell.MinimizeAll; 32 Button1.Tag := Button1.Tag + 1; 33 end; 34 1: {Displays the Run dialog} 35 begin 36 oShell.FileRun; 37 Button1.Tag := Button1.Tag + 1; 38 end; 39 2: {Displays the Shut Down Windows dialog} 40 begin 41 oShell.ShutdownWindows; 42 Button1.Tag := Button1.Tag + 1; 43 end; 44 3: {Displays the Find dialog} 45 begin 46 oShell.FindFiles; 47 Button1.Tag := Button1.Tag + 1; 48 end; 49 4: {Displays the Date/ Time dialog} 50 begin 51 oShell.SetTime; 52 Button1.Tag := Button1.Tag + 1; 53 end; 54 5: {Displays the Internet Properties dialog} 55 begin 56 oShell.ControlPanelItem('INETCPL.cpl'); 57 Button1.Tag := Button1.Tag + 1; 58 end; 59 6: {Enables user to select folder from Program Files} 60 begin 61 oShell.BrowseForFolder(0, 'My Programs', 0, 'C:\Program Files'); 62 Button1.Tag := Button1.Tag + 1; 63 end; 64 7: {Displays the Taskbar Properties dialog} 65 begin 66 oShell.TrayProperties; 67 Button1.Tag := Button1.Tag + 1; 68 end; 69 8: {Un-Minimizes all windows on the desktop} 70 begin 71 oShell.UndoMinimizeAll; 72 Button1.Tag := 0; 73 end; 74 end; 75 end; 76 77 procedure TForm1.Button1Click(Sender: TObject); 78 begin 79 oShell := CreateOleObject('Shell.Application'); 80 Shell(Button1.Tag); 81 oShell := VarNull; 82 end;