Recent

Author Topic: How to read output of Windows command line programs in Lazarus  (Read 8503 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1165
    • HowTos Considered Harmful?
I am trying to do this in Lazarus, however the program simply hangs.
What have I missed out?

Does Windows require a different method?

Code: [Select]
procedure GetIPConfigIniFile(var ipConfigOutput, iniFileOut:string);
var
   AProcess: TProcess;
   AStringList: TStringList;
   i, adapterPos, colonPos: integer;
begin
  AProcess := TProcess.Create(nil);
  AStringList := TStringList.Create;
  AProcess.CommandLine := 'ipconfig';
  AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
  AProcess.Execute;
end;
Lazarus 3.0/FPC 3.2.2

eny

  • Hero Member
  • *****
  • Posts: 1665
Re: How to read output of Windows command line programs in Lazarus
« Reply #1 on: March 05, 2010, 04:25:36 pm »
The wiki explains this.
HTH
All posts based on: Win11; stable Lazarus 4_4  (x64) 2026-02-12 (unless specified otherwise...)

vfclists

  • Hero Member
  • *****
  • Posts: 1165
    • HowTos Considered Harmful?
Re: How to read output of Windows command line programs in Lazarus
« Reply #2 on: March 05, 2010, 04:54:03 pm »
They don't work as expected.

Ping only works correctly with [poWaitOnExit, poUsePipes].
ipconfig only works correctly with  [poUsePipes].

Getting to find out what works and what doesn't is going to be painful.

The wiki explains this.
HTH
Lazarus 3.0/FPC 3.2.2

 

TinyPortal © 2005-2018