Win32::GuiConsole


Packaging and distribution for Perl code on Win32.
http://www.cava.co.uk/

 

 

Note: the Win32::GuiConsole utility and examples are now hosted at http://www.cava.co.uk/freetools. you should visit that site for up to date examples and code.

When an application starts as a GUI application, there can be some difficulty in then directing stdout and stderr to any console the gui application may open or attach to.

From MS Win documentation .....

When a GUI application is started in certain circumstances, the three standard OS handles STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, and STD_ERROR_HANDLE are all "zeroed out" by the console initialization routines. These three handles are replaced by valid values when the GUI application calls AllocConsole(). Therefore, once this is done, calling GetStdHandle() will always return valid handle values. The problem is that the CRT has already completed initialization before your application gets a chance to call AllocConsole(); the three low I/O handles 0, 1, and 2 have already been set up to use the original zeroed out OS handles, so all CRT I/O is sent to invalid OS handles and CRT output does not appear in the console.

Win32::GuiConsole provides the necessary redirection so that you may send STDOUT and STDERR to a console from a GUI application.

View Plain Old Documentation

Download PPM

Download Source

Win32::GuiConsole can be particularly useful in debugging Perl MSWin services packaged using PerlSvc or a PAR packed Win32::Daemon application. Example code of a PerlSvc script making use of Win32::GuiConsole is available:

PerlSvc Example

Also available is example code for Win32::Daemon with event logging

Win32::Daemon Service Example

 

 

 

 

 

 

 

 

 

 


www.gigi.co.uk  © 2005