• Advertisement

Archived

This topic is now archived and is closed to further replies.

How do I setup a DOS box with a Windows application?

This topic is 5876 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Howdy all, I''m writing this simple windowed DirectX application, but I would like to also have a DOS box appear and write logging messages to the DOS box during runtime. How can I do that? Thanks. Eric

Share this post


Link to post
Share on other sites
Advertisement

AllocConsole(); // Allocate the console
HANDLE out;
DWORD count;
out = GetStdHandle( STD_OUTPUT_HANDLE );
WriteConsole( out, "Test", 4, &count, NULL );
FreeConsole();


[edited by - jacksonh on March 22, 2002 5:50:41 PM]

Share this post


Link to post
Share on other sites
Just because it has a text-mode interface, that doesn''t make it DOS. DOS is an operating system.
What you call "DOS box" is called such only when command.com has been invoked, because that''s the command processor for DOS and requires the DOS virtual machine. Otherwise, the text-mode interface window you see is the console—Windows has a legitimate console subsystem that has nothing to do with DOS.

Share this post


Link to post
Share on other sites
You might find this helpful too.


  
#include <windows.h>
#include <stdarg.h>
#include <stdio.h>
/////////////////////////////////////////////////////////////////////////////

// F I L E P R I N T F O R M A T -------------------------------------------

// win32 style replacement for fprintf

INT __cdecl FilePrintFormat(HANDLE hFile, LPCTSTR format, ...)
{
TCHAR szBuffer[1024];
ZeroMemory(&szBuffer, sizeof(szBuffer) );
int retValue = 0;
DWORD cbWritten;
va_list argptr;

if ( hFile != INVALID_HANDLE_VALUE )
{
va_start( argptr, format );
retValue = wvsprintf( szBuffer, format, argptr );
va_end( argptr );
WriteFile( hFile, szBuffer, retValue, &cbWritten, (LPOVERLAPPED)NULL );
}
return retValue;
}

Share this post


Link to post
Share on other sites
quote:
Original post by siaspete
As far as I know, cmd.exe is a Win32 command prompt, not a DOS box.

I'm not entirely sure though, so let the flames begin!




No need for flames - My understanding is that cmd.exe is the NT equivalent to command.com - and so I brought it up. I agree that the proper terminology is 'console window' or 'command prompt' - but just the same, I cut my teeth on DOS 5.0 and still manage to slip up myself on occaission.

// Edit

For the record - the W2K version info for cmd.exe titles itself "Windows NT Command Processor"


[edited by - lessbread on March 23, 2002 5:16:54 PM]

Share this post


Link to post
Share on other sites
Sounds about right. I do think that COMMAND is based on DOS where CMD is NT (like you say).

Output from COMMAND:
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-1999.


Output from CMD:
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.


Hurray!


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites

  • Advertisement