亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

MFC|Console Output from a GUI program(MFC調用cout輸出)

2019-11-06 08:04:10
字體:
來源:轉載
供稿:網友

https://www.codePRoject.com/kb/cpp/editbin.aspx

Sample Image - EditBin.gif

Introduction

If you create a Windows program using the MFC application Wizard, the program will not show text output which has been sent to the Standard Output or Standard Error handles.

Visibility of the output may be desirable at some point in time for diagnostic or functional purposes. Or you may wish to add command line Operation of the program. Then to be consistent with command line operation, text should automatically be output to the command/dos window.

This article documents the use of EditBin utility to activate console mode operation of a Windows (or GUI ) program. (And for those who want some source code, the program contains an EditBin program relating to redirection of thecout stream object.)

Alternatives for obtaining text output

Run the Windows program from a command prompt and redirect the output using the redirection feature of the command window: ">out.txt" and "2>errors.txt"

Reassign the standard output and error output handles to be piped or sent to another file using::SetStdHandle(). This process seems to be tricky to achieve.

You may write a console program that remaps the stdout, stdin, andstderr provided to a spawned program. The spawn program would be the one which has the output that you want to collect.

The Microsoft EditBin Utility

EditBin.exe is found in the VC98/bin subpath of Visual Studio 6.

This obscure tool offers the key for enabling text console output from Windows mode programs written in Visual C++ 6 (or Visual Basic 6). You can toggle the program executable between Windows mode and console mode.

EditBin MyProgram.exe /SUBSYSTEM:CONSOLE EditBin MyProgram.exe /SUBSYSTEM:WINDOWS

Including the Editbin utility in the build process

The article image shows Visual Studio 6 Project Settings to show in situ how the Microsoft EditBin utility appears when added to become part of the build process.

The "Post-Build Step" tab of the Projects Settings dialog allows you to enter in a command on your final executable. The picture shows the example:

editbin /SUBSYTEM:CONSOLE $(OUTDIR)/iTHXTool.exe

Side Effect for a Console version of the program

The console window will be appear along with the application window. Such may be the desired option if you want to view diagnostic information. If you start the program from a command prompt, the command window will show the Standard Output and Standard Error text.

You may have to create two copies of your application: a strictly GUI program, and a command line version. The programs will involve the same compiled code, but one will be modified using the EditBin tool.

Also a Microsoft help entry mentioned that the file handles 0,1 and 2 (that should be equivalent somehow tostdout andstderr) do not get reassigned since these values are assigned in the CRT startup of the Windows program. (Yet you may be able to modify the CRT using the files from thevc98/CRT/source directory.)

One last observation on the VS6 project settings...

You may notice "/subsystem:windows" as appears in an MFC Wizard generated application under the Project Settings Link tab. Yet console output can't be obtained by simply changing this entry to/subsystem:console.

Some code for redirection of cout

The source code program here, provides an example for redirecting the cout stream object. For some reason(s), the source code doesn't properly redirect thestdout file handle, though various websites describe that thestdout should be redirectable.

The application consists of a text editor window that is automatically filled with the time of day at ten seconds intervals. The program relies on piped output which is being read by aReadFile call operating within a thread.

The heart of the redirection occurs within the initialization of the main application object. For all related code, search for the "April 2005" string which will lead you to all code modifications to the standard wizard generated code.

Initialization Steps

rval = CreatePipe(&hRead,&hWrite,0,0);rval = SetStdHandle(STD_OUTPUT_HANDLE,hWrite);//Now assign hWrite to stdout, coutFILE *fp;int hConHandle;long lStdHandle;lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);fp = _fdopen( hConHandle, "w" );// The stdout reassignment didn't seem to work// *stdout = *fp;  // redefine the stdout to point to the pipesetvbuf( fp, NULL, _IONBF, 0 ); // Filebuf object attached to "test.dat"filebuf *fb = new filebuf(_fileno(fp  ) );cout = fb;

This program shows a little bit of how redirection can be done. Note that the buffering of text (for text being inserted into the RTF document) is not designed ruggedly. The code bypasses the need to use the MicrosoftEditBin.exe tool in some but not all cases.

It would have been desirable to write the data to a memory file instead of sending data through a pipe. Then there would not have been a need to create a thread to watch the output of the pipe. Anyhow, the_open_osfhandle failed to convert a memory map handle to a typical file handle (inhConHandle).

Conclusion

The Windows GUI development doesn't conveniently support the access to cout,cerr,stdout, orstderr. It may be difficult to obtain these under direct control of the window program. At least there exist some tricks to obtain the information if really needed.

License

This article, along with any associated source code and files, is licensed underThe Code Project Open License (CPOL)


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
亚洲一区精品电影| 日韩国产精品亚洲а∨天堂免| 日韩成人中文电影| 91极品女神在线| 久久成人综合视频| 亚洲精品久久久久久久久久久久久| 欧美精品第一页在线播放| 国产欧美精品xxxx另类| 亚洲美女久久久| 国产欧美精品xxxx另类| 国产精品精品视频| 日韩大陆毛片av| 日韩av电影在线网| 成人国产在线激情| 青青精品视频播放| 亚洲欧美中文字幕| 色悠悠久久88| 亚洲日本aⅴ片在线观看香蕉| 国产一区二区三区在线播放免费观看| 欧美日韩视频免费播放| 在线视频欧美性高潮| 久久久久一本一区二区青青蜜月| 亚洲男人天堂九九视频| 91成人福利在线| 日本成人黄色片| 国产精品丝袜久久久久久不卡| 欧美一区二区三区免费视| 日本韩国欧美精品大片卡二| 国产亚洲精品美女| 日韩在线视频线视频免费网站| 久久精品国产成人| 伊人一区二区三区久久精品| 狠狠躁夜夜躁久久躁别揉| 亚洲美女av电影| 亚洲第一网站男人都懂| 国产精品18久久久久久首页狼| 91精品久久久久久久久久| 国产亚洲精品一区二区| 亚洲a区在线视频| 亚洲欧美国内爽妇网| 91九色蝌蚪国产| 国产日韩在线精品av| 亚洲成人在线网| 久久这里有精品视频| 日韩日本欧美亚洲| 国产精品香蕉av| 国语自产精品视频在线看抢先版图片| 欧美在线视频免费观看| 精品久久香蕉国产线看观看亚洲| 亚洲黄色有码视频| 97av在线播放| 欧美在线性爱视频| www.色综合| 欧美亚洲国产精品| 91精品国产沙发| 日韩av影片在线观看| 亚洲国产欧美一区二区三区久久| 国产精品色视频| 欧美老女人在线视频| 精品久久久在线观看| 成人在线免费观看视视频| 国产精品丝袜白浆摸在线| 国产91在线播放精品91| 欧美日韩国产黄| 91黄色8090| 另类少妇人与禽zozz0性伦| 欧美成人高清视频| 国产在线视频不卡| 国产精品一区二区久久| 另类专区欧美制服同性| 在线视频精品一| 日韩在线欧美在线| 中文字幕日韩精品在线观看| 日韩女优在线播放| 亚洲第一在线视频| 国产精品丝袜一区二区三区| 亚洲激情自拍图| 亚洲肉体裸体xxxx137| 国产精品一二三在线| 日韩在线观看免费| 国产精品视频资源| 欧美一级淫片丝袜脚交| 国产有码在线一区二区视频| 日韩欧美高清视频| 国产精品久久久久久久久免费| 欧美一区二区三区四区在线| 国内精品久久久久伊人av| 久久久久久噜噜噜久久久精品| 欧美性xxxxxxxxx| 欧美日本啪啪无遮挡网站| 欧美一区第一页| 亚洲精品欧美日韩专区| 成人乱人伦精品视频在线观看| 久久久亚洲国产天美传媒修理工| 午夜精品久久久久久久久久久久| 欧美国产日韩在线| 26uuu亚洲伊人春色| 国产精品高精视频免费| 国内免费精品永久在线视频| 国产999精品视频| 97免费中文视频在线观看| 日韩精品丝袜在线| 欧美第一淫aaasss性| 性色av一区二区三区在线观看| 欧美性xxxxxxxxx| 亚洲精品欧美日韩| 久久夜精品va视频免费观看| 免费91在线视频| 欧美日韩在线第一页| 国产精品老女人精品视频| 国产日韩在线免费| 亚洲国产精品视频在线观看| 中文字幕亚洲综合久久| 日韩欧美在线观看视频| 亚洲国产精品va在看黑人| www.99久久热国产日韩欧美.com| 韩国欧美亚洲国产| 97在线观看免费高清| 69久久夜色精品国产69| 美女久久久久久久久久久| 国产在线观看一区二区三区| 亚洲第一av在线| 亚洲国产婷婷香蕉久久久久久| 中文字幕亚洲专区| 欧美放荡办公室videos4k| 欧美放荡办公室videos4k| 精品国内产的精品视频在线观看| 91欧美精品午夜性色福利在线| 国产精品欧美日韩久久| 国产综合视频在线观看| 亚洲精品aⅴ中文字幕乱码| 亚洲午夜激情免费视频| 亚洲区免费影片| 成人久久久久久| 久久久久国产精品www| 亚洲男人av电影| 成人免费大片黄在线播放| 欧美精品videossex88| 日韩中文字幕国产| 国内外成人免费激情在线视频| 色狠狠久久aa北条麻妃| 久久成人人人人精品欧| 91老司机精品视频| 欧美丰满少妇xxxxx做受| 国产精品免费久久久久影院| 精品高清美女精品国产区| 国产成人在线一区二区| 久久精品国产亚洲精品| 久久久精品美女| 日本精品免费观看| 热99精品只有里视频精品| 亚洲色图综合网| 国产自产女人91一区在线观看| 91香蕉嫩草神马影院在线观看| 欧美寡妇偷汉性猛交| 一本色道久久88综合亚洲精品ⅰ| 亚洲欧美国产一区二区三区| 亚洲白虎美女被爆操| 国产成人免费91av在线| 日韩在线激情视频| 91免费视频网站| 国产精品情侣自拍| 欧美激情免费在线| 欧美日韩在线观看视频|