Something like below - I didn't have time to test it fully, but something is
printed when I shutdown.
use strict; use Win32::GUI qw (WM_QUERYENDSESSION); my $main =
Win32::GUI::Window->new(-name => 'Main', -text => 'Perl', -width => 200,
-height => 200);$main->AddLabel(-name => "Label", -text => "Hello, world",
-left => 20, -top => 20, -notify => 1);$main->Hook(WM_QUERYENDSESSION,\
&EndSession);$main->Show();Win32::GUI::Dialog();
sub EndSession { print "WM_QUERYENDSESSION fired\n"; return 0;}
> Date: Wed, 23 Dec 2009 23:41:11 +0100
> From: s...@h-k.fr
> To: jez_wh...@hotmail.com
> CC: perl-win32-gui-users@lists.sourceforge.net
> Subject: Re: [perl-win32-gui-users] Windows shutdown
>
>
> Hi Jeremy,
>
>
> | One thing that did strike me when reading your mail was when you said
> | "application does not in itself require a GUI". When you hooked
> | WM_QUERYENDSESSION + WM_ENDSESSION, are you sure your application is
> | sitting on the event pump (Win32::GUI::Dialog) when windows shuts down?
> | If it's not, then you wont get the messages before it's too late...
>
> I'm pretty sure my code isn't at all what it's supposed to look like :-)
> If it's not too much trouble, could you send a working example with these
> variables and Win32::GUI::Dialog ? The simplest things can be hell to put
> together in the right order when it's done for the first time...
>
>
> Thanks!
> Seb.
>
>
>
> | > Date: Wed, 23 Dec 2009 13:19:41 +0100
> | > From: s...@h-k.fr
> | > To: perl-win32-gui-users@lists.sourceforge.net
> | > Subject: [perl-win32-gui-users] Windows shutdown
> | >
> | >
> | > Hi folks,
> | >
> | >
> | > Here is the question: I'm looking for a minimal example of a (perl) script
> | > that dies (gracefully or not) when Windows tries to shutdown.
> | >
> | > Story: I have developed an application that monitors via RS232 the health
> | > of TV screens attached to PCs. The information gathered is relayed to a
> | > central server. This application must run continuously, but still die
> | > when an automatic shutdown is triggered on the PC. The application works
> | > but doesn't die when asked to (via Start->Stop).
> | >
> | > I have a fair knowledge of Perl and Unix, but I am totally new to Windows
> | > programming: don't hesitate to state an obvious solution :-) Please note
> | > that the application does not in itself require a GUI. I tried a GUI
> | > following the discussion here:
> | >
> http://objectmix.com/perl/20692-win32-how-quit-perl-script-during-log-off-automatically.html
> | > A solution that would use Win32::API would also work for me, I just
> | > thought it might be simpler with Win32::GUI.
> | > I have tried to use GetMessage and PeekMessage, but I'm clearly not using
> | > them the right way (again, I know zilsch about Windows programming).
> | >
> | > I've read the archives on mail-archive.com and found discussions dating
> | > back to 2001 and 2004; they do not provide a working example alas. I also
> | > tried to understand the man pages on CPAN and the samples in the tarball,
> | > but couldn't find a hint there either.
> | >
> | > Any hope, err, help, would be much appreciated!
> | >
> | >
> | > Seb.
> | >
> | >
> | >
> ------------------------------------------------------------------------------
> | > This SF.Net email is sponsored by the Verizon Developer Community
> | > Take advantage of Verizon's best-in-class app development support
> | > A streamlined, 14 day to market process makes app distribution fast and
> easy
> | > Join now and get one step closer to millions of Verizon customers
> | > http://p.sf.net/sfu/verizon-dev2dev
> | > _______________________________________________
> | > Perl-Win32-GUI-Users mailing list
> | > Perl-Win32-GUI-Users@lists.sourceforge.net
> | > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> | > http://perl-win32-gui.sourceforge.net/
> |
> | _________________________________________________________________
> | Use Hotmail to send and receive mail from your different email accounts
> | http://clk.atdmt.com/UKM/go/186394592/direct/01/
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
_________________________________________________________________
Use Hotmail to send and receive mail from your different email accounts
http://clk.atdmt.com/UKM/go/186394592/direct/01/
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/