Click here to Skip to main content
12,622,535 members (34,031 online)
Click here to Skip to main content
Add your own
alternative version


229 bookmarked

QuickWin - Turn a console application into a Windows program

, 17 Oct 2000
Rate this:
Please Sign up or sign in to vote.
Redirect stdin, stdout and stderr into a window
<!-- Download Links -->
  • Download source files - 105 Kb
  • Download executable - 18 Kb
  • Sample Image

    <!-- Main HTML starts here -->


    QuickWin is a Windows application that spawns a Win32 console application that redirecte its stdin, stdout and stderr handles to a window. The console application is hiden and all I/O operations are made through QuickWin.

    This is a very useful program to spawn script programs or console applications in a Window environment without opening a DOS box.

    How QuickWin works

    QuickWin contains one or two windows depending on if you want the same stdout view for stderr output or another view. stdin is in the same view as stdout. The view is a CRichEditView window and is not limited in space for the output. Commands like cut, copy, paste, find are also available. QuickView can spawn console applications, shell (COMMAND.COM or CMD.EXE) or batch files. You start the console application from the command line or browse your disk. You can also stop and restart the console application many times. The content of the output view can be saved to file. The last 10 programs are saved into the registry and available for quick start.

    The following parameters are available:

    Full or Half duplex.

    In full duplex, characters are send to stdin and displayed into the view. In half duplex, they are only send to stdin.


    The enter key (CR) can be translated into CR, LF or CR+LF.

    Close on Exit.

    If the console application is terminated, QuickWin will terminate.

    Show Child window.

    You can display the DOS box child window. If you want to write into this "Console", open the "CON" file and write into it.

    OEM -> Ansi.

    Normally, we must translate characters for console application.

    Use Input buffer.

    If it is not necessary to send each character one at a time to the stdin. Characters can be stored in an input buffer until CR is pressed.

    Command line.

    For COMMAND.COM or CMD.EXE, the command is echoed to stdout. This option removes the typed command.

    Options for COMMAND.COM or CMD.EXE.

    Fullduplex, CR->CR+LF,Oem->ANSI, Use input buffer and Command line.

    For standard applications, remove the Command line option.

    Main points of interest in the source code

    A CRedirect class that can be used in any WIN32 or MFC applications. This class contains four virtual functions for notification.

    virtual void OnChildStarted(LPCSTR lpszCmdLine);
    virtual void OnChildStdOutWrite(LPCSTR lpszOutput);
    virtual void OnChildStdErrWrite(LPCSTR lpszOutput);
    virtual void OnChildTerminate();

    The main program is an MFC application that uses the CRedirect class. PostThreadMessage is used to post commands in a multithread environment. WM_COPYDATA is used to post messages to the window.

    The MFC print preview bug is not corrected!

    Thanks to Paul DiLascia for some pieces of code from TraceWin.


    Date Posted: Oct.17-2000


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    Lanz Jean-Claude
    Switzerland Switzerland
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    Question2Tb Virtual Disk Pin
    nhchmg27-Jun-11 21:23
    membernhchmg27-Jun-11 21:23 
    GeneralMemory Leak after calling CMainFrame::ShowSplitter( FALSE ) [modified] Pin
    karel_tandd8-Jun-11 20:29
    memberkarel_tandd8-Jun-11 20:29 
    GeneralGreat Code and Solution - Thanks For Sharing Pin
    oldbritthumper8-Jan-10 4:27
    memberoldbritthumper8-Jan-10 4:27 
    Thank you for a wonderful program (and solution)!

    I have been trying to do just what QuickWin does for a couple of months now and only met with partial success.

    It all started with Microsoft's own code for "Creating a Child Process with Redirected Input and Output".

    Then I added in the code from 'Cedric' at (March 5th post) for his StdOutRedirect class and its code.

    I was able to get stuff working until I wanted to bring everything together under a Dialog-Based application (Visual Studio 2008).
    Never could - but QuickWin proves that you can!
    Now I have to pull *your* code apart to see how you do it!

    BTW, under Visual Studio 2008 there are two mods that I had to make to your code out-of-the-box to get it to compile and execute properly.
    They were solutions found in these posts:
    Airpatrol 4/24/04:

    Modify the following functions:

    void CRedir::OnChildStarted(LPCSTR lpszCmdLine)
    void CRedir::OnChildWrite(UINT OutputID, LPCSTR lpszOutput)

    The line CFrameWnd *pFrame = (CFrameWnd*)AfxGetMainWnd();
    should be changed to
    CFrameWnd *pFrame = (CFrameWnd*)AfxGetApp()->GetMainWnd();
    seclib 2/6/04:

    LPRESULT CQuickWinApp::OnStdioCommand(WPARAM wCommand, LPARAM lParam)
    void CQuickWinApp::OnStdioCommand(WPARAM wCommand, LPARAM lParam)

    and change
    afx_msg LPRESULT OnStdioCommand(WPARAM wParam, LPARAM lParam);
    afx_msg void OnStdioCommand(WPARAM wParam, LPARAM lParam);

    Again, I can't thank you enough for sharing this code with the rest of us.
    -Matt Smile | :)
    QuestionCrash,when dropfile into the app Pin
    suxiaojack1-Jul-08 18:27
    membersuxiaojack1-Jul-08 18:27 
    QuestionIssues in XP/VS2003 Pin
    John Lomen24-Oct-07 7:13
    memberJohn Lomen24-Oct-07 7:13 
    Generalkbhit that works on child stdin Pin
    mycal19-Sep-07 20:11
    membermycal19-Sep-07 20:11 
    QuestionSending ALT-] Pin
    kdekome21-Feb-07 7:47
    memberkdekome21-Feb-07 7:47 
    GeneralQuickWin Example for VB.Net Pin
    gprodri8-Feb-07 8:18
    membergprodri8-Feb-07 8:18 
    GeneralRe: QuickWin Example for VB.Net Pin
    berilium9-Feb-07 1:32
    memberberilium9-Feb-07 1:32 
    GeneralRe: QuickWin Example for VB.Net Pin
    berilium9-Feb-07 5:17
    memberberilium9-Feb-07 5:17 
    GeneralRe: QuickWin Example for VB.Net Pin
    berilium9-Feb-07 5:33
    memberberilium9-Feb-07 5:33 
    GeneralRe: QuickWin Example for VB.Net Pin
    gprodri9-Feb-07 7:32
    membergprodri9-Feb-07 7:32 
    GeneralRe: QuickWin Example for VB.Net Pin
    berilium27-Feb-07 0:47
    memberberilium27-Feb-07 0:47 
    GeneralCtrl+C and redirected console Pin
    axelsw3-Nov-06 8:19
    memberaxelsw3-Nov-06 8:19 
    GeneralRe: Ctrl+C and redirected console Pin
    jorgening19-Jan-07 8:47
    memberjorgening19-Jan-07 8:47 
    QuestionRedirect output form time critical application Pin
    MariuszGorczak18-Dec-05 6:14
    memberMariuszGorczak18-Dec-05 6:14 
    GeneralHaving trouble getting the output when implementing Redirect class Pin
    hackerjack1235-Dec-05 16:16
    memberhackerjack1235-Dec-05 16:16 
    GeneralRe: Having trouble getting the output when implementing Redirect class Pin
    tish18-Mar-14 2:34
    membertish18-Mar-14 2:34 
    GeneralAssertion on CRedirect Line 173 Pin
    Crercio O. Silva28-Aug-05 7:06
    memberCrercio O. Silva28-Aug-05 7:06 
    GeneralOutput is displayed after my console application exits Pin
    Hamid Reza Mohammadi20-Aug-05 22:53
    memberHamid Reza Mohammadi20-Aug-05 22:53 
    GeneralRe: Output is displayed after my console application exits Pin
    Hamid Reza Mohammadi27-Aug-05 8:23
    memberHamid Reza Mohammadi27-Aug-05 8:23 
    GeneralNot all console applications work Pin
    Stuart Konen5-Apr-05 9:46
    memberStuart Konen5-Apr-05 9:46 
    AnswerRe: Not all console applications work Pin
    LeFauve10-Oct-05 2:55
    memberLeFauve10-Oct-05 2:55 
    QuestionCan QuickWin Output be Redirected to a File? Pin
    jroeb24-Mar-05 9:06
    memberjroeb24-Mar-05 9:06 
    Generalwin console to wince Pin
    lagunasun6-Feb-05 17:58
    memberlagunasun6-Feb-05 17:58 
    QuestionWhat about redirecting standard output of your own app? Pin
    Luca Piccarreta24-Dec-04 2:01
    memberLuca Piccarreta24-Dec-04 2:01 
    AnswerRe: What about redirecting standard output of your own app? Pin
    Luca Piccarreta24-Dec-04 2:04
    memberLuca Piccarreta24-Dec-04 2:04 
    GeneralRe: What about redirecting standard output of your own app? Pin
    brusch1-Jul-05 8:25
    sussbrusch1-Jul-05 8:25 
    GeneralRe: What about redirecting standard output of your own app? Pin
    Anonymous13-Jul-05 3:02
    sussAnonymous13-Jul-05 3:02 
    GeneralRe: What about redirecting standard output of your own app? Pin
    ralle7211-Oct-06 23:39
    memberralle7211-Oct-06 23:39 
    Generalvery very helpful Pin
    Anonymous11-Oct-04 2:33
    sussAnonymous11-Oct-04 2:33 
    Generalvery very helpful Pin
    Anonymous11-Oct-04 2:32
    sussAnonymous11-Oct-04 2:32 
    Generalredirecting stdout without a new process Pin
    sammyc12-Sep-04 23:13
    membersammyc12-Sep-04 23:13 
    GeneralPlz help me Pin
    Qudrat22102-Jun-04 4:20
    sussQudrat22102-Jun-04 4:20 
    GeneralQuickwin.exe execution directory Pin
    Sub-Scum30-Dec-03 11:30
    sussSub-Scum30-Dec-03 11:30 
    QuestionHandle problem - Someone has a solution? Pin
    fato17-Dec-03 7:01
    memberfato17-Dec-03 7:01 
    AnswerApplication fix Pin
    fato29-Dec-03 1:13
    memberfato29-Dec-03 1:13 
    GeneralCompile Error under VS.NET 2003 on XP Pro Pin
    [DAve]5-Dec-03 6:26
    member[DAve]5-Dec-03 6:26 
    GeneralRe: Compile Error under VS.NET 2003 on XP Pro Pin
    seclib6-Feb-04 5:44
    memberseclib6-Feb-04 5:44 
    GeneralRe: Compile Error under VS.NET 2003 on XP Pro Pin
    [DAve]6-Feb-04 6:23
    member[DAve]6-Feb-04 6:23 
    GeneralRe: Compile Error under VS.NET 2003 on XP Pro Pin
    sars3-Apr-05 16:18
    membersars3-Apr-05 16:18 
    GeneralRe: Compile Error under VS.NET 2003 on XP Pro Pin
    Bobby Kolev4-Nov-05 6:07
    memberBobby Kolev4-Nov-05 6:07 
    Generaldisplaying calculation reports Pin
    RAIMONDI LUIGI26-Nov-03 23:00
    sussRAIMONDI LUIGI26-Nov-03 23:00 
    Generalvery well, thanx Pin
    pureman10-Nov-03 20:13
    memberpureman10-Nov-03 20:13 
    GeneralVery nice and usefull but... Pin
    /J4-Oct-03 22:10
    suss/J4-Oct-03 22:10 
    GeneralStream output does not work under Visual C++ .Net Pin
    adil_sbai13-Mar-03 8:37
    memberadil_sbai13-Mar-03 8:37 
    GeneralRe: Stream output does not work under Visual C++ .Net Pin
    Airpatrol24-Apr-04 19:50
    memberAirpatrol24-Apr-04 19:50 
    GeneralSorry, there already had a response Pin
    babou9416-Jan-03 22:14
    memberbabou9416-Jan-03 22:14 
    Generalno all the stdout is printed Pin
    babou9414-Jan-03 0:24
    memberbabou9414-Jan-03 0:24 
    GeneralCatch Main Messages Pin
    fassi12-Jan-03 7:04
    memberfassi12-Jan-03 7:04 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Terms of Use | Mobile
    Web02 | 2.8.161128.1 | Last Updated 18 Oct 2000
    Article Copyright 2000 by Lanz Jean-Claude
    Everything else Copyright © CodeProject, 1999-2016
    Layout: fixed | fluid