Click to See Complete Forum and Search --> : ReadFile, WriteFile in Console application
Mithila
December 28th, 2004, 01:14 AM
Hi,
Is it possible to use ReadFile,WriteFile in console application? If so , how to do it?
PLs help.
Mithila
Andreas Masur
December 28th, 2004, 06:07 AM
Yes...since they are simple API functions, there is not any problem...just include the correct header (windows.h) and use them as you would use them in a non-console application...
Boris K K
December 29th, 2004, 10:00 AM
If you want to read from the console input / write to the console output using ReadFile/WriteFile, use CreateFile("CONIN$", ...) / CreateFile("CONOUT$", ...), respectively.
To read from the standard input / write to the standard output use GetStdHandle(STD_INPUT_HANDLE) / GetStdHandle(STD_OUTPUT_HANDLE).
The difference between console input/output and standard input/output is that the latter can be redirected (to/from file, for example).
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.