Article View: borland.public.cppbuilder.nativeapi
Article #15285Re: Monitoring what a user's doing
From: Pete Fraser
Date: Tue, 15 Jul 2003 15:24
Date: Tue, 15 Jul 2003 15:24
51 lines
2668 bytes
2668 bytes
The only problem with this is that
a) When I run this console command and use the X box to close it, I get an
AV which the debugger doesn't know where it is! (The same thing happens when
I log off) :(
b) Won't this leave resources that I use open and thus leak? I'd like to
clean up when shutting down.
Apart from the shut down problems I've got a basic version going :)
Rgds Pete
"Max Topley" <mtj2@btopenworld.com> wrote in message
news:ek08hvcfc4kiq18mqhs6kjkt3nlc7uf5vk@4ax.com...
On Tue, 15 Jul 2003 14:06:13 +0100, Pete Fraser wrote:
>How does a console app get shut down? Does it need to set up a message
queue
>to get shutdown messages from windows? I've not done this kind of (always
>running) app before :(
Console apps don't use the GUI at all by default, so there are no
windows or message queues, though you can create them if you wish.
The app will simply be terminated by Windows on user logout (happens
automatically on shutdown).
I'd probably write something like:
int main(int argc, char* argv[])
{
int secsused = 0 ;
for ( ;; )
{
Sleep( 1000) ;
if ( MessengerActive() && ++secsused > SECSALLOWED )
KillMessenger() ;
}
return 0;
}
You might want to write the time used into the registry in the loop,
and read it back at startup, to prevent the little monsters from
simply rebooting. Easy enough to allow for a daily budget, as well.
>I will probably keep the Service based app for later on when I feel braver!
It's certainly pretty advanced stuff :o((
--
Max
Technical Details
Message-ID:
<3f141c94@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3f13de65$1@newsgroups.borland.com> <t6p7hvsgvjr8bkm3f9l4jo034d8d59bprq@4ax.com> <3f13fc45@newsgroups.borland.com> <ek08hvcfc4kiq18mqhs6kjkt3nlc7uf5vk@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,c2e41c15dcc5c61d X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-15 08:38:06 PST From: "Pete Fraser" <pete.fraser@at.frasersoft.dot.net> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f13de65$1@newsgroups.borland.com> <t6p7hvsgvjr8bkm3f9l4jo034d8d59bprq@4ax.com> <3f13fc45@newsgroups.borland.com> <ek08hvcfc4kiq18mqhs6kjkt3nlc7uf5vk@4ax.com> Subject: Re: Monitoring what a user's doing Date: Tue, 15 Jul 2003 16:24:04 +0100 Lines: 53 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: 195.12.18.1 Message-ID: <3f141c94@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1058282644 195.12.18.1 (15 Jul 2003 08:24:04 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail