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