www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Console Output

reply Trevor Parscal <trevorparscal hotmail.com> writes:
Does anyone know of a way to output to a console even if a WinMain 
function is present. It seems like this should be simple..

-- 
Thanks,
Trevor Parscal
www.trevorparscal.com
trevorparscal hotmail.com
May 31 2005
next sibling parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
Do not include .def file while linking and you'll be able to use
printf in console.

Andrew.

"Trevor Parscal" <trevorparscal hotmail.com> wrote in message 
news:d7ioc7$2p9l$1 digitaldaemon.com...
 Does anyone know of a way to output to a console even if a WinMain 
 function is present. It seems like this should be simple..

 -- 
 Thanks,
 Trevor Parscal
 www.trevorparscal.com
 trevorparscal hotmail.com 
May 31 2005
prev sibling next sibling parent reply Derek Parnell <derek psych.ward> writes:
On Tue, 31 May 2005 15:27:16 -0700, Trevor Parscal wrote:

 Does anyone know of a way to output to a console even if a WinMain 
 function is present. It seems like this should be simple..
It sort of is... look up the Windows SDK for AllocConsole, GetStdHandle, WriteConsole, ReadConsoleInput, and FreeConsole. There a re a few other functions available to, but these are the basic ones. -- Derek Melbourne, Australia 1/06/2005 9:37:12 AM
May 31 2005
parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
"Derek Parnell" <derek psych.ward> wrote in message 
news:1pmj54hl4v7jy$.j6m1vccfnsy2$.dlg 40tude.net...
 On Tue, 31 May 2005 15:27:16 -0700, Trevor Parscal wrote:

 Does anyone know of a way to output to a console even if a WinMain
 function is present. It seems like this should be simple..
It sort of is... look up the Windows SDK for AllocConsole, GetStdHandle, WriteConsole, ReadConsoleInput, and FreeConsole. There a re a few other functions available to, but these are the basic ones.
Sacred knowledge: http://www.digitalmars.com/d/archives/digitalmars/D/learn/52.html
May 31 2005
prev sibling next sibling parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
And one more solution:

dwritef  - writef into debugging console (VisualStudio or WinDbg)

version(Windows)
{
  extern (Windows)
  {
    export void OutputDebugStringA(char* lpOutputString);
  }
}

debug void dwritef(...)
{
    char[] s;
    void putc(dchar c)
    {
      std.utf.encode(s, c);
    }
    std.format.doFormat(&putc, _arguments, _argptr);

    version(Windows)
    {
      OutputDebugStringA(s);
    }
} else void dwritef(...) {}
May 31 2005
prev sibling parent David L. Davis <SpottedTiger yahoo.com> writes:
In article <d7ioc7$2p9l$1 digitaldaemon.com>, Trevor Parscal says...
Does anyone know of a way to output to a console even if a WinMain 
function is present. It seems like this should be simple..

-- 
Thanks,
Trevor Parscal
www.trevorparscal.com
trevorparscal hotmail.com
Trevor, You may find the D converted version of wincon.h, renamed to wincon.d on my site useful...there's also two very useful examples included in the download. Just look for the "Fun with the NT / XP Console in D", which is the bottom entry of the following web page. http://spottedtiger.tripod.com/D_Language/D_Hub_Adv_Tutor_XP.html David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" ------------------------------------------------------------------- MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
May 31 2005