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

Started by
11 comments, last by Codegod 22 years ago
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
Advertisement
AllocConsole(); // Allocate the consoleHANDLE 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]
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.
quote:Original post by merlin9x9
... only when command.com has been invoked ...


Don''t forget cmd.exe...
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Pardon my old DOS terminology. I meant command prompt. Is that better?
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!

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
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 fprintfINT __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;}  
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
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]
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
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
How do I set the properties for the console, such as window and buffer sizes??

Thanks.

This topic is closed to new replies.

Advertisement