private
procedure winexit(var msg:tmessage);message wm_queryendsession;
------------------------------------------------------------------
procedure tform1.winexit(var msg:tmessage);
begin
msg.result:=1;
application.ProcessMessages;
application.Terminate;
end;