home *** CD-ROM | disk | FTP | other *** search
- unit UnitFrmDummyRunner;
- {
- Purpose:
- This form controls the startup process by creating/removing
- the system tray icon and running the behind the sense processes.
-
- Updates:
- Icon notification for new items and double click will open the Edit
- form and hilight new itesm
- }
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ShellAPI,
- UnitStartupMover, UnitStartupRunner, ImgList;
-
- const MY_WM_TRAYICON = WM_USER + 1; // used to receive tray icon messsages
- type
- TfrmDummyRunner = class(TForm)
- ImageList1: TImageList;
- procedure FormDestroy(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- sm : TStartupMover;
- sr : TStartupRunner;
- TrayIcon: TNotifyIconData; {tray icon info}
- procedure WMTrayIcon(var Msg: TMessage); message MY_WM_TRAYICON;
- public
- { Public declarations }
- procedure DoYourThing;
- end;
-
- var
- frmDummyRunner: TfrmDummyRunner;
-
- implementation
-
- Uses UnitFormEdit, UnitRegistryManager;
-
- {$R *.dfm}
-
- procedure TFrmDummyRunner.DoYourThing;
- var icon : TIcon;
- begin
- sm := TStartupMover.Create(self.Handle);
- sr := TStartupRunner.Create(self.Handle);
-
- //
- // Create System Tray Icon
- //
- TrayIcon.cbSize := SizeOf(TrayIcon);
- TrayIcon.Wnd := Self.Handle;
- TrayIcon.uID := 0;
- TrayIcon.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
- TrayIcon.uCallbackMessage := 0;
- TrayIcon.hIcon := Application.Icon.Handle;
- TrayIcon.szTip := 'StartRight';
- ShellAPI.Shell_notifyIcon(NIM_ADD, @TrayIcon);
-
-
- Windows.Sleep(5000);
- // copy new stuff, run everything
- //
- // NOTE: The autoexcluder will check for duplicate entries
- // in my startup locations, and windows locations that may
- // have occured after the last time StartRight was run.
-
- {AutoExcluder.Run;}
- RegistryManager.AutoExcludeRunkeyItems;
- RegistryManager.AutoExcludeStartupItems;
-
- sm.MoveRunKeyItems;
- sm.MoveStartupFolderItems;
- sr.ExecuteRunkeyPrograms;
- sr.ExecuteStartupFolderPrograms;
-
-
-
- //
- // Remove tray icon
- //
- ShellAPI.Shell_notifyIcon(NIM_DELETE, @TrayIcon);
-
- //
- // show the 'New Items' icon - if needed
- if (sm.GetHasNewItems) then begin
- icon := TIcon.Create;
- ImageList1.GetIcon(1, icon);
-
- TrayIcon.cbSize := SizeOf(TrayIcon);
- TrayIcon.Wnd := Self.Handle;
- TrayIcon.uID := 0;
- TrayIcon.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
- TrayIcon.uCallbackMessage := MY_WM_TRAYICON;
- TrayIcon.hIcon := Icon.Handle;
- TrayIcon.szTip := 'StartRight - New Items found';
- ShellAPI.Shell_notifyIcon(NIM_ADD, @TrayIcon);
-
- icon.Free;
- end else begin
- Application.Terminate;
- end;
- end;
-
- procedure TFrmDummyRunner.WMTrayIcon(var Msg: TMessage);
- begin
- //
- // show the edit form and hilight the new items
- //
- if (Msg.lparam = WM_LBUTTONDBLCLK) or
- (Msg.lparam = WM_LBUTTONDBLCLK) then begin
- ShellAPI.Shell_notifyIcon(NIM_DELETE, @TrayIcon);
-
- FrmEdit.SetEndProgramOnClose(true);
- FrmEdit.ShowNewItems;
- end;
-
- end;
-
-
-
- procedure TfrmDummyRunner.FormDestroy(Sender: TObject);
- begin
- sm.Free;
- sr.Free;
- end;
-
- procedure TfrmDummyRunner.FormCreate(Sender: TObject);
- begin
- if (ParamCount <> 0) then self.DoYourThing;
- end;
-
- end.
-