Re: How to keep my com exe alive?



A small (seemingly silly :)) ) question. If I wnat my exe to be
terminated only at the time of shutdown or user log off (the forceful
termionation) how would I handle this issue.
Will I be able to take any action when the exe is forcefully
terminated?
Thanks,
Shaji

Alexander Nickolov wrote:
You have to decide how does your executable terminate -
when does it decide to do so.

As for trapping WM_QUIT - you don't have to - simply
insert your code after the message loop.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

"shaji" <shajiparemmal@xxxxxxxxx> wrote in message
news:1141900821.832271.200760@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Igor,
Thanks for this.
Overriding PostMessageLoop works when the Module.Lock() is not used. If
I use the Lock() and does not call Unlock() anywhere, the exe will go
down only when the system shuts down, right?
Now, what I am looking for is a way to trap the WM_QUIT that is sent to
my exe when the system shuts down and save my internal data at that
time.
Is that possible? If yes, how can I do it?
Thanks,
Shaji.

Igor Tandetnik wrote:
"shaji" <shajiparemmal@xxxxxxxxx> wrote in message
news:1141820689.598628.253300@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
1. I want to keep my com exe (just one ATL COM object - free threaded
- dual interface) running even after all the clients have quit. But I
don't want to make it a service.

Call _Module.Lock() to keep yourself alive. Call Unlock() when you
finally decide it's time to terminate.

2. When the exe shuts down, I want to save some internal data (in
fact, an stl list) onto the disk so that it can be read when next
time the exe starts up

Override PostMessageLoop in your CAtlExeModule-derived class.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: ActiveX Exe does not terminate
    ... When I terminate it as stand-alone it is fine - all traces of it ... > and the Activex appears to close but is still listed by Task Manager, ... > the ActiveX Exe attemps to close? ...
    (microsoft.public.vb.com)
  • Re: Application caching
    ... Normal and expected behavior is ... for an exe file to be locked when the application is in use. ... The way I have tackled it in the past is to have an app shutdown/restart ... In another case I created a program that would terminate all running ...
    (microsoft.public.windows.terminal_services)
  • Re: Initializing and terminating a dll in ASP.NET
    ... > applications hosted under the same exe. ... > in more than 1 app domain, the dll will get loaded again. ... > | terminate the dll earlier on lets say page unload, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: how to run exe. file on a computer which dont have .Net
    ... > computer which dont have visual studio .Net installed on it. ... > the .Net framework on that computer and ran my exe. ... > "Application terminated, click ok to terminate the application and cancel ...
    (microsoft.public.dotnet.framework)
  • Re: How to keep my com exe alive?
    ... Overriding PostMessageLoop works when the Module.Lockis not used. ... I use the Lock() and does not call Unlock() anywhere, the exe will go ...
    (microsoft.public.vc.atl)

Loading