Read the friendly manual first.
I am not sure whether freopen() opens in FILE_SHARE_WRITE mode. If it doesn't 
you might have to use CreateFile() directly.

--------------------------------
From Windows SDK documentations:

Consoles
The CreateFile function can create a handle to console input (CONIN$). If the 
process has an open handle to it as a result of inheritance or duplication, it 
can also create a handle to the active screen buffer (CONOUT$). The calling 
process must be attached to an inherited console or one allocated by the Alloc 
console function. For console handles, set the CreateFile parameters as follows.
(...)

Use the CONOUT$ value to specify console output.
(...)

dwDesiredAccess GENERIC_READ | GENERIC_WRITE is preferred, but either one can 
limit access. 
dwShareMode When opening CONIN$, specify FILE_SHARE_READ. When opening CONOUT$, 
specify FILE_SHARE_WRITE.
(...)

lpFileName dwDesiredAccess Result 
CON GENERIC_READ Opens console for input. 
CON GENERIC_WRITE Opens console for output. 
CON GENERIC_READ | GENERIC_WRITE Causes CreateFile to fail; GetLastError 
returns ERROR_FILE_NOT_FOUND.  

------------------                               
Best regards,
lh_mouse
2014-12-05

-------------------------------------------------------------
发件人:Mark Cianfaglione <m.cianfagli...@valydate.com>
发送日期:2014-12-05 04:28
收件人:mingw-w64-public
抄送:
主题:[Mingw-w64-public] redirectable output in under windows

Folks

I know this might be a little off list but does anyone have a good way
(in C) of being able to switch debug output from a file to console?

I tired a method where I used freopen("CON","w+", stdout)but it always
seems to fail. I saw this on a website (stupidly I didn't bookmark it)
and the similar /dev/tty in Linux works great.( I have compile time
switches)

Is CON a legal special filename for Windows? Or is there something I'm
missing?

Mark



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to