News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Console question

Started by Ghirai, August 05, 2005, 05:24:58 PM

Previous topic - Next topic

Ghirai

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.
MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html

Mark Jones

Start your console app from within the GUI app:


    invoke ShellExecute,hWnd,0,addr MyFilePath,0,0,SW_HIDE
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

hitchhikr

CreatePipe -> CreateProcess -> WaitForSingleObject -> ReadFile -> etc.

Ghirai

Thanks, you're right, i forgot about that.
MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html

Ghirai

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.
MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html

hitchhikr

What might be hidden inside that mysterious PeekNamedPipe ?

Ghirai

Yeah, that was it.
Works fine now.
MASM32 Project/RadASM mirror - http://ghirai.com/hutch/mmi.html