Recent

Author Topic: Controlling another process executed by T(Async)Process' process  (Read 11564 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8768
  • Programming + Glam Metal + Tae Kwon Do = Me
I want to build Windows' cmd wrapper because I want larger view and tabbed interface. I saw some projects on the net like eConsole (Delphi) and Console2 (inspired by eConsole, but written in C++), both can handle how cmd executes another program (and both uses Windows API's CreateProcess). That is, they can suppress console window created by that another program. However in fpc (or Lazarus) case, even if I set ShowWindow to swoNone and one of Options is poNoConsole, program still opens console window.

If it's not really clear what I mean, please see attached screenshot. As you can see, the output of fpc in Console2 (left) is written on the memo, while my app (right) opens a console window.

Troodon

  • Sr. Member
  • ****
  • Posts: 484
Re: Controlling another process executed by T(Async)Process' process
« Reply #1 on: April 06, 2010, 07:09:36 am »
Just a coment: I have noticed a similar behaviour upon trying to launch mplayer embedded in a Windows app using poNoConsole: the mplayer console window will pop-up anyway. That doesn't happen in Linux, though. I had a quick look at how the MPlayer GUI folks worked around this issue (Delphi 7 code) and they appear to collect output using pipes.

Update: the issue is no longer apparent with MPlayer-athlon-svn-31027.
« Last Edit: April 09, 2010, 04:58:09 pm by Troodon »
Lazarus/FPC on Linux

Leledumbo

  • Hero Member
  • *****
  • Posts: 8768
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Controlling another process executed by T(Async)Process' process
« Reply #2 on: April 06, 2010, 10:03:08 am »
Update: I can now redirect all output to memo, using poNewConsole. But then a blank console opens. How can I close it?

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Controlling another process executed by T(Async)Process' process
« Reply #3 on: April 06, 2010, 10:54:22 am »
Does it depend on compiler setting "Win32 GUI" (-WG)?
Lazarus 1.7 (SVN) FPC 3.0.0

Leledumbo

  • Hero Member
  • *****
  • Posts: 8768
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Controlling another process executed by T(Async)Process' process
« Reply #4 on: April 07, 2010, 01:54:42 pm »
Quote
Does it depend on compiler setting "Win32 GUI" (-WG)?
Nope, it's for the main application, not a child process that we execute. So, basically here's what happened:
Code: [Select]
My app (1)
   | executes using TProcess
cmd (2)
   | executes using ... something implemented by MS, CreateProcess perhaps
whatever sent to cmd (3)
poNoConsole:
no command prompt window for (2), but yes for (3). (3) output is sent to the command prompt window

poNewConsole:
command prompt window for (2), but empty. (3) output is sent to (2).

eny

  • Hero Member
  • *****
  • Posts: 1644
Re: Controlling another process executed by T(Async)Process' process
« Reply #5 on: April 07, 2010, 03:35:52 pm »
swoHide works for me.
All posts based on: Win10 (Win64); Lazarus 3_4  (x64) 25-05-2024 (unless specified otherwise...)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8768
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Controlling another process executed by T(Async)Process' process
« Reply #6 on: April 09, 2010, 07:38:27 am »
Quote
swoHide works for me.
:o
OK, didn't notice that it should be swoHIDE. Thanks.

 

TinyPortal © 2005-2018