Help Center

CWhsExec.CONSTRUCTORconstructor

Creates an instance of the `CWhsExec` class.

Windowsconstructordocumented

Syntax

CONSTRUCTOR CWhsExec (BYREF wszCommand AS WSTRING)

Parameters

NameDescription
wszCommandThe command to execute.

Description

Creates an instance of the CWhsExec class.

Runs an application in a child command-shell, providing access to the StdIn/StdOut/StdErr streams.

Example

#include "AfxNova/AfxWsh.inc" #include "AfxNova/CTextStream.inc" USING AfxNova DIM pWshExec AS CWhsExec = "%comspec% /c dir" IF pWshExec THEN DIM pStdOutStm AS CTextStream = pWshExec.GetStdOut IF pStdOutStm THEN

IF pStdOutStm.EOS = FALSE THEN
     ' // The console uses the CP_OEMCP code page
     DIM dwsOut AS DWSTRING
     dwsOut.OEM = pStdOutStm.ReadAll
     ' // You can also use
     ' DIM dwsOut AS DWSTRING = DWSTRING(pStdOutStm.ReadAll, CP_OEMCP)
     print dwsOut
  END IF

END IF END IF

Reference

  • Defined in AfxNova/AfxWsh.inc:277
  • Documented in Windows/Windows Script/Windows Shell.md
  • Topic: Windows Shell