Page 1 of 1
Posted: Sat Feb 22, 2003 6:03 am
by BackupUser
Restored from previous forum. Originally posted by ricardo.
Hi,
Im trying to code a small console app, but i try to from my console an external dos command or another console app but i get another console open and i want it to display inside my console... am i doing something wrong?
Lets say i want to run dir or any other DOS command inside my console, not opening a new DOS prompt.
Best Regards
Ricardo
Dont cry for me Argentina...
Posted: Sat Feb 22, 2003 8:04 am
by BackupUser
Restored from previous forum. Originally posted by TheBeck.
Hi Ricardo,
I think you are going to have to use pipes. This will let the command you are calling communicate with your console application and presumably send it's output to your app so you can display it in your own console. I will let you know if I find out more.
Quote from win32.hlp:
A pipe is a communication conduit with two ends: a process with a handle to one end can communicate with a process having a handle to the other end. This overview describes how to create, manage, and use pipes.
-Nathan Beckstrand
Posted: Sat Feb 22, 2003 1:03 pm
by BackupUser
Restored from previous forum. Originally posted by Rings.
ricardo, take a look at this:
viewtopic.php?t=3704
Its a long way to the top if you wanna .....CodeGuru
Posted: Sat Feb 22, 2003 1:13 pm
by BackupUser
Restored from previous forum. Originally posted by TheBeck.
You are supposed to use CreateProcess() but I couldn't get it to work so I used the old WinExec() API. It is much simpler!
Code: Select all
OpenConsole()
Print("Press SPACE to get directory")
Repeat
Delay(50)
Until Left(Inkey(),1) = " "
ApplicationName.s = "cmd.exe /c dir"
If WinExec_(@ApplicationName.s, #SW_SHOWNORMAL) = 0
MessageRequester("ERROR", Str(GetLastError_()) , #PB_MessageRequester_Ok)
EndIf
Repeat
Delay(50)
ForEver
End
Posted: Sat Feb 22, 2003 3:40 pm
by BackupUser
Restored from previous forum. Originally posted by ricardo.
Hi,
This WinExec() works perfect... now i have here a typical console : )
Thanks The_Beck !!
@Rings:
On your code... is there a way to write to the proccess? i mean 'interact' (write and read).?
Best Regards
Ricardo
Dont cry for me Argentina...