summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Win32.pod14
-rw-r--r--win32/win32.c31
-rw-r--r--win32/win32.h6
3 files changed, 51 insertions, 0 deletions
diff --git a/lib/Win32.pod b/lib/Win32.pod
index 842e484fc6..95f7562e5e 100644
--- a/lib/Win32.pod
+++ b/lib/Win32.pod
@@ -253,6 +253,20 @@ The function returns the menu id of the selected push button:
[EXT] Loads the DLL LIBRARYNAME and calls the function DllRegisterServer.
+=item Win32::SetChildShowWindow(SHOWWINDOW)
+
+[CORE] Sets the I<ShowMode> of child processes started by system().
+By default system() will create a new console window for child
+processes if Perl itself is not running from a console. Calling
+SetChildShowWindow(0) will make these new console windows invisible.
+Calling SetChildShowWindow() without arguments reverts system() to the
+default behavior. The return value of SetChildShowWindow() is the
+previous setting or C<undef>.
+
+[EXT] The following symbolic constants for SHOWWINDOW are available
+(but not exported) from the Win32 module: SW_HIDE, SW_SHOWNORMAL,
+SW_SHOWMINIMIZED, SW_SHOWMAXIMIZED and SW_SHOWNOACTIVATE.
+
=item Win32::SetCwd(NEWDIRECTORY)
[CORE] Sets the current active drive and directory. This function does not
diff --git a/win32/win32.c b/win32/win32.c
index 52d0924a9c..e0cdfc0532 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -3667,6 +3667,10 @@ win32_spawnvp(int mode, const char *cmdname, const char *const *argv)
else {
create |= CREATE_NEW_CONSOLE;
}
+ if (w32_use_showwindow) {
+ StartupInfo.dwFlags |= STARTF_USESHOWWINDOW;
+ StartupInfo.wShowWindow = w32_showwindow;
+ }
DEBUG_p(PerlIO_printf(Perl_debug_log, "Spawning [%s] with [%s]\n",
cname,cmd));
@@ -4003,6 +4007,32 @@ win32_dynaload(const char* filename)
*/
static
+XS(w32_SetChildShowWindow)
+{
+ dXSARGS;
+ BOOL use_showwindow = w32_use_showwindow;
+ /* use "unsigned short" because Perl has redefined "WORD" */
+ unsigned short showwindow = w32_showwindow;
+
+ if (items > 1)
+ Perl_croak(aTHX_ "usage: Win32::SetChildShowWindow($showwindow)");
+
+ if (items == 0 || !SvOK(ST(0)))
+ w32_use_showwindow = FALSE;
+ else {
+ w32_use_showwindow = TRUE;
+ w32_showwindow = (unsigned short)SvIV(ST(0));
+ }
+
+ EXTEND(SP, 1);
+ if (use_showwindow)
+ ST(0) = sv_2mortal(newSViv(showwindow));
+ else
+ ST(0) = &PL_sv_undef;
+ XSRETURN(1);
+}
+
+static
XS(w32_GetCwd)
{
dXSARGS;
@@ -4488,6 +4518,7 @@ Perl_init_os_extras(void)
newXS("Win32::GetLongPathName", w32_GetLongPathName, file);
newXS("Win32::CopyFile", w32_CopyFile, file);
newXS("Win32::Sleep", w32_Sleep, file);
+ newXS("Win32::SetChildShowWindow", w32_SetChildShowWindow, file);
/* XXX Bloat Alert! The following Activeware preloads really
* ought to be part of Win32::Sys::*, so they're not included
diff --git a/win32/win32.h b/win32/win32.h
index f5c04b68da..299d8f1ed5 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -353,6 +353,8 @@ struct thread_intern {
# ifdef USE_RTL_THREAD_API
void * retv; /* slot for thread return value */
# endif
+ BOOL Wuse_showwindow;
+ WORD Wshowwindow;
};
#ifdef USE_5005THREADS
@@ -421,12 +423,16 @@ DllExport int win32_async_check(pTHX);
# define w32_crypt_buffer (thr->i.Wcrypt_buffer)
# define w32_servent (thr->i.Wservent)
# define w32_init_socktype (thr->i.Winit_socktype)
+# define w32_use_showwindow (thr->i.Wuse_showwindow)
+# define w32_showwindow (thr->i.Wshowwindow)
#else
# define w32_strerror_buffer (PL_sys_intern.thr_intern.Wstrerror_buffer)
# define w32_getlogin_buffer (PL_sys_intern.thr_intern.Wgetlogin_buffer)
# define w32_crypt_buffer (PL_sys_intern.thr_intern.Wcrypt_buffer)
# define w32_servent (PL_sys_intern.thr_intern.Wservent)
# define w32_init_socktype (PL_sys_intern.thr_intern.Winit_socktype)
+# define w32_use_showwindow (PL_sys_intern.thr_intern.Wuse_showwindow)
+# define w32_showwindow (PL_sys_intern.thr_intern.Wshowwindow)
#endif /* USE_5005THREADS */
/* UNICODE<>ANSI translation helpers */