Can´t Exit Windows while my program is running.

I made a port blocker that is autostarted with windows, but every time I want to exit windows i must close my program. Why? How do I fix it?
SwOoPeAsked:
Who is Participating?
 
intheConnect With a Mentor Commented:
Hi
add this to your program:

    procedure WMQueryEndSession(var Msg: TWMQueryEndSession) ;
      message WM_QUERYENDSESSION ;


procedure TForm1.WMQueryEndSession(var Msg: TWMQueryEndSession);
const
  CAN_SHUTDOWN = 0 ;
  DONT_SHUTDOWN = 1 ;
begin
  inherited ;
  if something then { something can be a glabal boolean or comment out the line}
    Msg.Result := CAN_SHUTDOWN
  else {either comment this out or use with the global boolean}
    Msg.Result := DONT_SHUTDOWN ;
end;


Regards Barry
0
 
SwOoPeAuthor Commented:
I haven´t tryed it yet but thanks for your reply.

David
0
 
SwOoPeAuthor Commented:
damm inthe it diden´t work. Do u have any other solotions to this problem?

Can be becouse I use:

procedure WndProc(var Msg : TMessage);

for a tray icon?
0
 
intheCommented:
for a start try commenting out all the tray icon code(as far as im aware these are the 2 most normal faults for this problem is tray icon and wm_queryendsession).
see if it works then
0
All Courses

From novice to tech pro — start learning today.