About: Capture Console Output Realtime To Memo   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

The code below allows to perform a command and capture it's output. The captured output is sent 'real-time' to the Memo parameter. Sending the output 'real-time' to the memo will make the enduser not think the application is hanging while performing the command.

AttributesValues
rdfs:label
  • Capture Console Output Realtime To Memo
rdfs:comment
  • The code below allows to perform a command and capture it's output. The captured output is sent 'real-time' to the Memo parameter. Sending the output 'real-time' to the memo will make the enduser not think the application is hanging while performing the command.
dcterms:subject
abstract
  • The code below allows to perform a command and capture it's output. The captured output is sent 'real-time' to the Memo parameter. Sending the output 'real-time' to the memo will make the enduser not think the application is hanging while performing the command. procedure CaptureConsoleOutput(const ACommand, AParameters: String; AMemo: TMemo); const CReadBuffer = 2400; var saSecurity: TSecurityAttributes; hRead: THandle; hWrite: THandle; suiStartup: TStartupInfo; piProcess: TProcessInformation; pBuffer: array[0..CReadBuffer] of Char; dRead: DWord; dRunning: DWord; begin saSecurity.nLength := SizeOf(TSecurityAttributes); saSecurity.bInheritHandle := True; saSecurity.lpSecurityDescriptor := nil; if CreatePipe(hRead, hWrite, @saSecurity, 0) then begin FillChar(suiStartup, SizeOf(TStartupInfo), #0); suiStartup.cb := SizeOf(TStartupInfo); suiStartup.hStdInput := hRead; suiStartup.hStdOutput := hWrite; suiStartup.hStdError := hWrite; suiStartup.dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW; suiStartup.wShowWindow := SW_HIDE; if CreateProcess(nil, PChar(ACommand + ' ' + AParameters), @saSecurity, @saSecurity, True, NORMAL_PRIORITY_CLASS, nil, nil, suiStartup, piProcess) then begin repeat dRunning := WaitForSingleObject(piProcess.hProcess, 100); Application.ProcessMessages(); repeat dRead := 0; ReadFile(hRead, pBuffer[0], CReadBuffer, dRead, nil); pBuffer[dRead] := #0; OemToAnsi(pBuffer, pBuffer); AMemo.Lines.Add(String(pBuffer)); until (dRead < CReadBuffer); until (dRunning <> WAIT_TIMEOUT); CloseHandle(piProcess.hProcess); CloseHandle(piProcess.hThread); end; CloseHandle(hRead); CloseHandle(hWrite); end; end;
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software