Article View: borland.public.cppbuilder.nativeapi
Article #12870Re: Application notification on Machine restart or shutdown
From: Conny H�kansson
Date: Tue, 11 Nov 2003 22:28
Date: Tue, 11 Nov 2003 22:28
58 lines
3183 bytes
3183 bytes
Oh man that was fast.... And also answers on all my questions, amd very helpful answers. Can't tell you enough how much i appreciate it... T H A N K Y O U V E R Y M U C H /C "Remy Lebeau (TeamB)" <gambit47.no.spam@no.spam.yahoo.com> wrote in message news:3fb15956$1@newsgroups.borland.com... > > "Conny H�kansson" <conny@allimac.se> wrote in message > news:3fb15541@newsgroups.borland.com... > > > Now that i know that this is a teadious task to accomplish I > > want to know what messages to look for when using a > > traditional application that is started when a user is login in > > to the computer, and when he is login out. > > Under WinXP and 20003 only, you can use WTSRegisterSessionNotification() to > request the WM_WTSSESSION_CHANGE messages be sent to your app. This is not > available on any of the other Windows OSs. For those, there are no messages > for login, and for logout you can simply catch the WM_QUERYENDSESSION or > WM_ENDSESSION message, which will tell you whether it is a logout or a > shutdown. > > > Do I need to setup a system wide hook with the SetWindowsHookEx > > function, which demands a DLL file to store the callback procedure > > or is there a much simpler method to do this? > > No, you do not need a global hook at all. For a normal app, just intercept > the desired messages in your form's WndProc() method, or alternatively use > the TApplication::HookMainWindow() method to hook the hidden TApplication > window (some messages may go there instead of to any of your forms). > > > I want some work to be processed when the user is login in, > > aswell as when he logout's. > > In order to detect a login, your app must be executing as a service to begin > with so that it is running before the login occurs. For a normal app, that > requires registering the app under the "RunServices" key in the Registry, > and for the app to call RegisterServiceProcess() when it first starts up and > also when it is being terminated. That will also allow the app to survive a > logout (which normally shuts down all non-service apps) by intercepting and > ignoring WM_ENDSESSION from killing the app. > > > Gambit > >
Technical Details
Message-ID:
<3fb1609a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fb15541@newsgroups.borland.com> <3fb15956$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10cc67,c54773486c2a14af X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-11-11 14:39:54 PST From: "Conny H�kansson" <conny@allimac.se> Newsgroups: borland.public.cppbuilder.nativeapi References: <3fb15541@newsgroups.borland.com> <3fb15956$1@newsgroups.borland.com> Subject: Re: Application notification on Machine restart or shutdown Date: Tue, 11 Nov 2003 23:28:10 +0100 Lines: 60 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 217.215.164.250 Message-ID: <3fb1609a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1068589210 217.215.164.250 (11 Nov 2003 14:20:10 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail