unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellApi;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ntid: TnotifyIconDataA;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ntid.cbSize := sizeof(TnotifyIconDataA);
ntid.Wnd := Handle;
//ntid.uID := iid;
ntid.uFlags := NIF_ICON + NIF_TIP + NIF_MESSAGE;
//ntid.uCallbackMessage := mymsg;
ntid.hIcon := application.Icon.Handle;
ntid.szTip := '网上报车(通知、审批)系统';
shell_notifyicona(NIM_ADD,@ntid);
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// ntid要是全局变量,删除的时候其实都不需要设置什么了
shell_notifyicona(NIM_DELETE,@ntid);
Application.Terminate;
end;
end.