Say i have a console app, that's running, and from time to time adds some text to the console window.
What i want to do, is to hide the console, and write a windowed application, that gets the text from the console, and diaslays it in a textbox.
I was thinking in starting the console app (and removing it from the taskbar) with "consoleapp.exe >> out.txt", and constantly checking if there's new text. What do you think?
Thanks.
Start your console app from within the GUI app:
invoke ShellExecute,hWnd,0,addr MyFilePath,0,0,SW_HIDE
CreatePipe -> CreateProcess -> WaitForSingleObject -> ReadFile -> etc.
Thanks, you're right, i forgot about that.
Can't figure out what's wrong here.
GetData proc hDlg:dword
.while bStop!=1
invoke PeekNamedPipe,Read1,0,0,0,addr lpNumberOfBytesRead,0
.while lpNumberOfBytesRead
invoke ReadFile,Read1,addr buffer,MAX_PATH,addr lpNumberOfBytesRead,0
.if !eax
.break
.else
invoke SendDlgItemMessage,hDlg,IDC_TXT_LOG,EM_REPLACESEL,0,addr buffer
invoke SendDlgItemMessage,hDlg,IDC_TXT_LOG,EM_SETSEL,-1,0
.endif
invoke PeekNamedPipe,Read1,0,0,0,addr lpNumberOfBytesRead,0
.endw
.endw
This thread is called after createprocess. It works, but if the console app displays some text after say 30 seconds after start, it doesn't work.
The code above only seems to get the starting text.
What might be hidden inside that mysterious PeekNamedPipe ?
Yeah, that was it.
Works fine now.