2011. január 3., hétfő
Call the menu items of the Windows Start Menu programmatically
Problem/Question/Abstract:
How to call the menu items of the Windows Start Menu programmatically
Answer:
{ ... }
uses
Windows, Messages, SysUtils, 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;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése