I noticed a couple examples of "capturing stdout" using the WINAPI over at viewtopic.php?t=1016
I know that "CreatePipe()" isn't "smaller or portable" but I want to be able to capture stdout without having the console "pop up" or "flash"...
Anyone have any "open pipe" alternative code they want to share?
Or, is there a way to force any "console" windows to be MINIMIZED by default?
OPEN PIPE alternatives
Re: OPEN PIPE alternatives
Using fb open pipe command with minimized console.
Code: Select all
#include "windows.bi"
Function pipeout(Byval s As String="") Byref As String
Var f=Freefile
Dim As String tmp
Open Pipe s For Input As #f
s=""
Do Until Eof(f)
Line Input #f,tmp
s+=tmp+Chr(10)
Loop
Close #f
Return s
End Function
sub savefile(filename As String,p As String)
Dim As long n=freefile
If Open (filename For Binary Access Write As #n)=0 Then
Put #n,,p
Close
Else
Print "Unable to save " + filename:sleep:end
End If
End sub
ShowWindow( getconsolewindow(), SW_MINIMIZE )
var s=pipeout("dir /w")
savefile("directory.txt",s)
shell "notepad "+"directory.txt"
kill "directory.txt"
SendMessage(getconsolewindow(), WM_CLOSE, 0, 0)
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: OPEN PIPE alternatives
Have a look at https://users.freebasic-portal.de/grind ... /bipipe.bi, function bipOpen. Use SW_MINIMIZE as showmode value.
Re: OPEN PIPE alternatives
Wow! Guys!! Thanks for the replies!!! : )