Re: Executing system() command without console popping ...

From: Doug Harrison [MVP] (dsh_at_mvps.org)
Date: 02/08/05


Date: Tue, 08 Feb 2005 16:15:28 -0600

William DePalo [MVP VC++] wrote:

>"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
>news:4k3i01pvpumjaot8m8jk6lbk8utpscapa5@4ax.com...
>> I recommend doing both, as SW_HIDE doesn't seem to hurt anything,
>
>I don't think it does either, Doug. But I just wonder about the possibility
>for confusion when on the one hand you tell a function not to create a
>window and on the other tell it to hide it.
>
>In any event, I just now set the default for cmd windows to be full-screen
>and tried my hack again on XP/SP2. No window that I could see, no switch to
>full-screen mode.
>
>Then I copied the hack to an old and slow 2K box, set the default to be
>full-screen and got the same result.
>
>I wonder if the results depend on the image that the created process runs?

If the hack is to use CREATE_NO_WINDOW, that's the solution to the problem,
and I approve of the hack! :) The problem is caused by using SW_HIDE by
itself, which apparently is what most people have been doing for years, and
what my example demonstrated. The SW_HIDE method is pretty much the only
option for Win9X, where CREATE_NO_WINDOW isn't supported. For NT, SW_HIDE
continues to work modulo the problem I described, and breaking SW_HIDE
completely would mess up a lot of programs, including VC6 and VS.NET, not to
mention everyone who followed MS examples such as the one in that KB article
I cited. That said, to avoid the full-screen problem in NT, you _must_ use
CREATE_NO_WINDOW.

It turns out I'm more paranoid than I remember. I only "use both" on
NT-based Windows. On Win9X, I just use SW_HIDE. Here's my CreateProcess
setup code:

   PROCESS_INFORMATION p;
   STARTUPINFO s = { sizeof(STARTUPINFO) };
   s.dwFlags = STARTF_USESHOWWINDOW;
   s.wShowWindow = SW_HIDE;
   DWORD creationFlags = 0;
   if (OsVersion::AtLeastNT4())
      creationFlags |= CREATE_NO_WINDOW;

I've found this works well across the board.

-- 
Doug Harrison
Microsoft MVP - Visual C++


Relevant Pages

  • Re: Executing system() command without console popping ...
    ... > I recommend doing both, as SW_HIDE doesn't seem to hurt anything, ... I don't think it does either, Doug. ... window and on the other tell it to hide it. ... Then I copied the hack to an old and slow 2K box, ...
    (microsoft.public.vc.language)
  • Re: Possible to time out a popup?
    ... Microsoft MVP ... | I converted your example into a div under the progress bar. ... | portion was taken from a complete window example posted by Torgeir Bakken, ... Torgeir credits the technique used to a suggestion in a post ...
    (microsoft.public.scripting.vbscript)
  • Re: My first thread... program-wise that is
    ... WHen I get frustrated working on my current project (which is not a billable project), ... A thread must not touch any window that it ... >>let the main GUI thread do the updates of the controls. ... >>my MVP Tips site. ...
    (microsoft.public.vc.mfc)
  • Re: Cant start computer up
    ... "Pegasus (MVP)" wrote: ... ctrl+alt+delete that window comes up. ... Thats it though." ...
    (microsoft.public.windowsxp.general)
  • Re: window opens automatically at startup.
    ... Window is Program Files/Dell. ... Ken Blake, Microsoft MVP Windows - Shell/User ...
    (microsoft.public.windowsxp.general)

Quantcast