Win32::Process::Create

2008-04-28 Thread Michael Ellery
..I use this function pretty regularly to spawn procs on windows, but 
I've often wanted to minimize the console or main window that was 
launched.  Does anyone know how to do this?  In the corresponding WIN32 
API, there is a STARTUPINFO structure that allows this, but looks like 
it's not part of the Win32::Process API.  Advice appreciated.

-Mike Ellery

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Win32::Process::Create

2008-04-28 Thread Sisyphus

- Original Message - 
From: Michael Ellery [EMAIL PROTECTED]
To: 'perl-win32-users' perl-win32-users@listserv.ActiveState.com
Sent: Tuesday, April 29, 2008 5:24 AM
Subject: Win32::Process::Create


 ..I use this function pretty regularly to spawn procs on windows, but
 I've often wanted to minimize the console or main window that was
 launched.  Does anyone know how to do this?  In the corresponding WIN32
 API, there is a STARTUPINFO structure that allows this, but looks like
 it's not part of the Win32::Process API.  Advice appreciated.

Jst a couple of thoughts - I don't have time to test any of this out at the 
moment.

What happens if you launch the script using the wperl executable instead of 
the perl executable ?

Have you checked the various flags constants ? From the docs:

--
EXPORTS
The following constants are exported by default:

CREATE_DEFAULT_ERROR_MODE
CREATE_NEW_CONSOLE
CREATE_NEW_PROCESS_GROUP
CREATE_NO_WINDOW
CREATE_SEPARATE_WOW_VDM
CREATE_SUSPENDED
CREATE_UNICODE_ENVIRONMENT
DEBUG_ONLY_THIS_PROCESS
DEBUG_PROCESS
DETACHED_PROCESS
HIGH_PRIORITY_CLASS
IDLE_PRIORITY_CLASS
INFINITE
NORMAL_PRIORITY_CLASS
REALTIME_PRIORITY_CLASS
THREAD_PRIORITY_ABOVE_NORMAL
THREAD_PRIORITY_BELOW_NORMAL
THREAD_PRIORITY_ERROR_RETURN
THREAD_PRIORITY_HIGHEST
THREAD_PRIORITY_IDLE
THREAD_PRIORITY_LOWEST
THREAD_PRIORITY_NORMAL
THREAD_PRIORITY_TIME_CRITICAL

The following additional constants are exported by request only:

STILL_ACTIVE
--

I was thinking specifically of CREATE_NO_WINDOW constant (but perhaps that 
does something else).

Cheers,
Rob 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Win32::Process::Create

2008-04-28 Thread Michael Ellery
Sisyphus wrote:

 
 What happens if you launch the script using the wperl executable instead 
 of the perl executable ?
 

I don't even know what wperl is, although it does look like it's part of 
my current perl install (I have never heard of it before now). In any 
event, it's not an option for us since most of our stuff runs in the 
context of the perlSE.dll (ActiveScript engine).

 Have you checked the various flags constants ? From the docs:
 
 --
 EXPORTS
The following constants are exported by default:
 
CREATE_DEFAULT_ERROR_MODE
SNIP
 --
 
 I was thinking specifically of CREATE_NO_WINDOW constant (but perhaps 
 that does something else).
 

I believe this corresponds to this process creation flag (from MSDN docs):


CREATE_NO_WINDOW
0x0800

The process is a console application that is being run without a console 
window. Therefore, the console handle for the application is not set.

This flag is ignored if the application is not a console application, or 
if it is used with either CREATE_NEW_CONSOLE or DETACHED_PROCESS.


I'm really looking for something that works more generally (for console 
and non-console apps alike).  In older versions of the win32 API, I'm 
pretty sure there was a field in the STARTUPINFO that allowed the caller 
to request the app be started mimimized, but the current docs don't show 
such an option.

Perhaps my best bet it to try to call ShowWindow directly ??




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32::Process::Create

2008-04-28 Thread Jan Dubois
On Mon, 28 Apr 2008, Michael Ellery wrote:
 
 ..I use this function pretty regularly to spawn procs on windows, but
 I've often wanted to minimize the console or main window that was
 launched.  Does anyone know how to do this?  In the corresponding WIN32
 API, there is a STARTUPINFO structure that allows this, but looks like
 it's not part of the Win32::Process API.  Advice appreciated.

You cannot do this currently with Win32::Process, so you may want
to file an enhancement request at

http://rt.cpan.org/Public/Dist/Display.html?Name=Win32-Process

You could achieve the functionality with the standard system()
function though.  Just call e.g.

Win32::SetChildShowWindow(Win32::SW_SHOWMINIMIZED);
or
Win32::SetChildShowWindow(Win32::SW_HIDE);

to run processes minimized, or even without a window at all.
See `perldoc Win32` for the Win32SetChildShowWindow() docs.

If you need to wait for your subprocesses, then you may want
to use this somewhat obscure form:

my $pid = system(1, $cmdline);
# ...
waitpid $pid, 0;

(This is documented in `perldoc perlport` as a Win32 specific extension
to system(), but not mentioned in `perldoc -f system`).

Cheers,
-Jan


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs