obscurifer
Technical User
I want to write a program in Perl that sits and waits for Windows to shut down, then does something. I know that I have to use the Win32::Event module, and I have some code that I've written here.
========
use Win32::Event;
$manual = 0;
$initial = 0;
$name = "WM_QUERYENDSESSION";
$event = Win32::Event->new($manual,$initial,$name);
$event->wait();
open(OUTFILE, ">>c:/testout.txt" or die "Can't open file: $!";
print OUTFILE "Goodbye at " . scalar localtime() . "\n";
close OUTFILE;
========
If I set $name to some arbitrary event name, and then write another program that generates that event, this script will write to c:/testout.txt. If I run it as shown, I get nothing written to the file.
I suspect that WM_QUERYENDSESSION really talks to perl.exe (or wperl.exe) and not to my script, but I don't know that for sure.
So, the question is whether I can handle this event easily in Perl, or do I have to do something in C or some other compiled language?
TIA for all replies.
vrj
========
use Win32::Event;
$manual = 0;
$initial = 0;
$name = "WM_QUERYENDSESSION";
$event = Win32::Event->new($manual,$initial,$name);
$event->wait();
open(OUTFILE, ">>c:/testout.txt" or die "Can't open file: $!";
print OUTFILE "Goodbye at " . scalar localtime() . "\n";
close OUTFILE;
========
If I set $name to some arbitrary event name, and then write another program that generates that event, this script will write to c:/testout.txt. If I run it as shown, I get nothing written to the file.
I suspect that WM_QUERYENDSESSION really talks to perl.exe (or wperl.exe) and not to my script, but I don't know that for sure.
So, the question is whether I can handle this event easily in Perl, or do I have to do something in C or some other compiled language?
TIA for all replies.
vrj