ReadFromStdInput – Read from standard input stream

ReadFromStdInput – Read from standard input stream

Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) _    As LongPrivate Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, _    lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, _    lpNumberOfBytesRead As Long, lpOverlapped As Any) As LongPrivate Const STD_INPUT_HANDLE = -10&' read a number of chars from standard input channel'' if NumBytes < 0 then it reads all the bytes' from the standard input'' NOTE: this routine works only in compiled applicationsFunction ReadFromStdInput(Optional ByVal NumBytes As Long = -1) As String    Dim hStdIn As Long    Dim ret As Long    Dim buffer As String    Dim bytesRead As Long        ' get the handle of standard input    hStdIn = GetStdHandle(STD_INPUT_HANDLE)        ' prepare receiving buffer    buffer = Space$(1024)        Do        ' read from standard input        ret = ReadFile(hStdIn, ByVal buffer, Len(buffer), bytesRead, ByVal 0&)            ' deal with errors        If ret = 0 Then            Err.Raise 1001, , "Unable to read from standard input"        End If                ' append to result built so far        ReadFromStdInput = ReadFromStdInput & Left$(buffer, bytesRead)                ' continue to read if there are more chars    Loop Until bytesRead < Len(buffer)        End Function

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved