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:
Share on facebook
Share on twitter
Share on linkedin


The Latest

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a