Board index » delphi » Shutting down com server on windows exit or logoff

Shutting down com server on windows exit or logoff

Hi, y'all

I have an out of process com server which visually runs in the system tray,
started on windows startup. ComServer.OnLastRelease is handled to tell
windows not to unload the exe because i want to maintain some cross process
variables in it (such as login params, etc). The problem i am running into
is :

when Windows is shutting down or logoff is occurring, system failes to
unload the exe. Tried everything i could find on the newsgroups about
handling WM_ENDSESSION, WM_QUERYENDSESSION, FormCloseQuery, etc. No luck. At
the time of shutdown or logoff server _is_ running in the tray and main for
is hidden. Environment : Winnt 4.0, Ie4

Any clues?

Igor

Ps: pls reply to email, if you can : inaks...@sprynet.com or
inaks...@{*word*104}plus.com

TIA.

 

Re:Shutting down com server on windows exit or logoff


Heyas,

Just an idea, but you could try creating a dummy window whose only purpose
is to detect the WM_QUERYENDSESSION or WM_ENDSESSION messages.  Then you
could set up a call into your server to shut down (of course then anyone
could shut you down by making the call, so another way would be a good
idea.)

I would suggest using the Win32 API for creating your dummy window, much
less overhead than using a TForm.

HTH,

Michael

______________________

Quote
{*word*104}Plus wrote in message <6icj6f$i...@forums.borland.com>...
>Hi, y'all

>I have an out of process com server which visually runs in the system tray,
>started on windows startup. ComServer.OnLastRelease is handled to tell
>windows not to unload the exe because i want to maintain some cross process
>variables in it (such as login params, etc). The problem i am running into
>is :

>when Windows is shutting down or logoff is occurring, system failes to
>unload the exe. Tried everything i could find on the newsgroups about
>handling WM_ENDSESSION, WM_QUERYENDSESSION, FormCloseQuery, etc. No luck.
At
>the time of shutdown or logoff server _is_ running in the tray and main for
>is hidden. Environment : Winnt 4.0, Ie4

>Any clues?

>Igor

>Ps: pls reply to email, if you can : inaks...@sprynet.com or
>inaks...@{*word*104}plus.com

>TIA.

Re:Shutting down com server on windows exit or logoff


Michael,

Thanks. I already have that - server has main window which gets hidden when
minimized (goes into tray) and restoired when you activate tray icon (menu,
dblclick, etc). From what I understand, this window should be receiving
queryendsession msg, since it's application's main window. But that's just
not the case. Puzzled...

Igor.

Quote
Michael Robinson <_no_spam_s...@san.rr.com_no_spam_> wrote in message

<6idbf8$jl...@forums.borland.com>...
Quote
>Heyas,

>Just an idea, but you could try creating a dummy window whose only purpose
>is to detect the WM_QUERYENDSESSION or WM_ENDSESSION messages.  Then you
>could set up a call into your server to shut down (of course then anyone
>could shut you down by making the call, so another way would be a good
>idea.)

>I would suggest using the Win32 API for creating your dummy window, much
>less overhead than using a TForm.

>HTH,

>Michael

>______________________

>{*word*104}Plus wrote in message <6icj6f$i...@forums.borland.com>...
>>Hi, y'all

>>I have an out of process com server which visually runs in the system
tray,
>>started on windows startup. ComServer.OnLastRelease is handled to tell
>>windows not to unload the exe because i want to maintain some cross
process
>>variables in it (such as login params, etc). The problem i am running into
>>is :

>>when Windows is shutting down or logoff is occurring, system failes to
>>unload the exe. Tried everything i could find on the newsgroups about
>>handling WM_ENDSESSION, WM_QUERYENDSESSION, FormCloseQuery, etc. No luck.
>At
>>the time of shutdown or logoff server _is_ running in the tray and main
for
>>is hidden. Environment : Winnt 4.0, Ie4

>>Any clues?

>>Igor

>>Ps: pls reply to email, if you can : inaks...@sprynet.com or
>>inaks...@{*word*104}plus.com

>>TIA.

Re:Shutting down com server on windows exit or logoff


Hi Igor,

Quote
> Thanks. I already have that - server has main window which gets hidden when
> minimized (goes into tray) and restoired when you activate tray icon (menu,
> dblclick, etc). From what I understand, this window should be receiving
> queryendsession msg, since it's application's main window. But that's just
> not the case. Puzzled...

> Igor.

Had the same some time ago. The key is the tray icon.
You're probably using one of the freeware components to do it.
It's message handler function is wrong. Specifically, it treats it's
own message's (Click, DoubleClick etc.) but not the standard messages.
So it implicitely answers 0 to WM_CLOSEQUERY (because it answers 0 to
anything it doesn't understand).

Add a case for WM_CLOSEQUERY and return 1 and the thing will close.
If You don't get it to work, mail me. I'll send You a fixed version.

Anyway. I'm not sure what a tray icon should do with messages it
doesn't handle. Call the Windows' standard handler or else? Should
look at an 'official' Microsoft tray icon example...

Thomas

-----------------------------------------------------------------
Thomas Schimming
EPFL: Ecole Polytechnique Federale de Lausanne
CH-1015 Lausanne, Suisse
email: Thomas.Schimm...@epfl.ch
www: http://circwww.epfl.ch/~schimmin/
-----------------------------------------------------------------

"Your theory is crazy, but it's not crazy enough to be true."

                                        Bertolt Brecht

Other Threads