Board index » delphi » WM_QUERYENDSESSION, WM_ENDSESSION

WM_QUERYENDSESSION, WM_ENDSESSION

Hello,

I have developed a couple of COM-Server EXEs, which don't have any
Mainwindow. For this reason, the main code of the application looks like
this:

while getMessage(aMessage,0,0,0) do begin
    TranslateMessage(aMessage);
    DispatchMessage(aMessage);
end;

When I shutdown the Workstation (Windows NT4), the loop doesn't terminate.
Instead I get after a longer waiting time some Messages "Programm doesn't
react" and I have to kill it the hard way. I tried this:

if aMessage.message = WM_ENDSESSION then break;
or
if aMessage.message = WM_QUERYENDSESSION then break;
or
if aMessage.message = WM_ENDSESSION then postQuitMessage(0);

but nothings works.

Since there is also a COM-client which creates a bidirectional-connection
with an Interface-Callback, this client should get a chance to detach from
the Server bevor it's getting canceled. I thought, I could to this in the
application.onEvent (the client has a Mainwindow), but unfortunatly this
doesn't work either. Any ideas, helps, suggestions?

Thanks a lot

Joerg Wuennemann

 

Re:WM_QUERYENDSESSION, WM_ENDSESSION


Try something like:

TForm
        ....
        procedure WMQueryEndSession(var Message: TWMQueryEndSession); Message
WM_QUERYENDSESSION;
        ....

implementation

procedure TForm.WMQueryEndSession(var Message: TWMQueryEndSession);
begin
     Message.Result:=1;
end;

Other Threads