[EMAIL PROTECTED] wrote:
> I have a Perl script running on Windows that functions as a wrapper
> to a second program -- a compiled executable I cannot change. Within
> my Perl script, I use 'system' to call the second program and wait
> for it to return -- pretty basic. However, the second program calls
> ExitWindows() when it eventually ends (a few minutes to a few hours
> later), so my Perl script gets control back just long enough to print
> a line before perl (or wperl) gets terminated by Windows. What I need
> is for the Perl script to stay alive long enough to log this event to
> a file before Windows finishes logging out.        
> 
> A Windows GUI program could intercept the WM_QUERYENDSESSION message
> it receives as Windows logs out, so it could have a few seconds to do
> what it needs to do before responding to the message that it is ready
> to terminate (cf.
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/bas
e/exitwindows.asp).
> 
> Is there any similar functionality available in Perl or a module or
> would this require hacking the perl source? I didn't find anything
> after a search through CPAN and on the web.  

[Disclaimer: I am definitely NOT a Win32 expert!] But your Perl program is a
Console mode program, so you need to register a handler with
SetConsoleCtrlHandler(), I think.

If you look here:

   http://search.cpan.org/src/GSAR/libwin32-0.191/Console/Console.xs

you can see some code in Win32::Console that looks tempting. But the code is
commented out! Maybe you can check with the module's maintainer to see what
the situation is...

Good luck

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to