Can C++Builder Form Application wait until termination on command prompt ?

Hello Experts,

C++Builder XE5, Windows 7 64bit

When I run C++Builder Form Application on command prompt, it returns immediately without waiting its termination.
I want to show some messages with fprintf(stderr or stdout) in my form application, but I don't know how to setup my form application.

Any hints welcome,
Nobuo Miwa
Nobuo MiwaSecurity EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chaauCommented:
You can "wait" for the program completion in the batch files using one of the following methods:
START /wait notepad.exe 

Open in new window

or
CALL notepad.exe 

Open in new window

Both of these commands will wait for the program to complete before proceeding to the next line.
If you call the program on its own, like this:
notepad.exe

Open in new window


The next line in the batch file will be executed immediately.
(NB: replace notepad.exe with the name and path of your program)
0
jkrCommented:
If you are creating a Windows GUI application (which I presume), there simply is no stdout or stderr. What you can do to display diagnostic information is using 'OutputDebugString()' (http://msdn.microsoft.com/en-us/library/windows/desktop/aa363362(v=vs.85).aspx) and watch the output e.g. using "DebugView" (http://msdn.microsoft.com/en-us/vstudio/bb896647)

Alternatively you can of course wite your diagnostic output to a file using 'fprintf()', but I prefer the lhat method.
0
Nobuo MiwaSecurity EngineerAuthor Commented:
Thanks quick advice,

I tried both, but that could not print string from printf("hello\n").
I want to print it in command prompt.

Regards,
Nobuo Miwa
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

jkrCommented:
Again: When you are launching a GUI application, there is no command prompt. At least none related to that application. GUI apps just detach from command prompts, see the docs on 'CreateProcess()' (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx)
0
chaauCommented:
I think you need to read this article. It is a little bit dated, but in my opinion still relevant. The idea described in this article is to use a project for the console application and just create the Windows Form. The piece of code that creates the form in the console application is closer to the end of this article:
        // Create an instance of the TForm
        // class and show the form.
        TForm1* Form1 = new TForm1(0);
        int x = Form1->ShowModal();

        // Enable the console window and
        // bring it to the top.
        EnableWindow(hWnd, true);
        BringWindowToTop(hWnd);

        // Display the results of the modal form.
        cout << endl << "Modal result: " << x << endl;
        cout << endl <<  "Press any key to continue...";
        getch();
        delete Form1;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nobuo MiwaSecurity EngineerAuthor Commented:
Thank you for advice.
You let me know unknown things.
I will find out another way to return result of my app without printf().

Thank you again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.