eVC: Starting other app and writing a file

Posted on 2006-10-19
Last Modified: 2013-11-20

embeddedVisual C++-QUESTION!

I'm normally a .NET-Coder für CF, so I am kind'a new to eVC.
I need a very small application which only function is:

executing another application
writing a string "done" to a file in the same directory as the application

in .NET it would be some few lines of code, but I just dont know enough C++
to do it in eVC...

If someone could give me the code for this, I would be veeeery happy and

Question by:Ruttensoft
  • 4
  • 3
LVL 22

Expert Comment

ID: 17763884
>>in .NET it would be some few lines of code, but I just dont know enough C++ to do it in eVC...

   you may use CreateProcess() to start another appliation and wait for exit something like

        CreateProcess( (_T("Process.exe"), NULL, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi ); //Start Process... replace Process.exe with ur app path string
        WaitForSingleObject( pi.hProcess, INFINITE );

// Now open file and write to file using CFile or CStdioFile MFC Class


Author Comment

ID: 17763909
Thanks I will have a look at it. Where can I enter a comandline-string? at the first null?
Can it be just "-hello" or do I have to _T("-hello"), or something like that?
Sorry but I'm very new to C++...

LVL 22

Accepted Solution

mahesh1402 earned 500 total points
ID: 17763932
You can input command line arguments to CreateProcess() function's 2nd parameter

CreateProcess(_T("App.exe"),_T("-Argument1 -Argument2")........

For more have a look at :
INFO: Understanding CreateProcess and Command-line Arguments :

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Author Comment

ID: 17763939
Thanks and how do I exit a eVC-App by code?
LVL 22

Expert Comment

ID: 17763955
what do you mean by exit a eVC-App by code ?

Above code given by me will start process wait for process execution and exit......and if you want to terminate started process at any time then remove WaitForSingleObject() function from above and you may use TerminateProcess () API




Author Comment

ID: 17764014

Sorry for my unprecise question.
I want that the app does not wait until the started process has terminated. I want the app to terminate itself, the started process should not quit...

Thanks so much
LVL 22

Expert Comment

ID: 17764026
then that your application should take care of iteself to terminate usign exit() or so.....
but there is no difference if application exits itself or it terminate using WaitForSingleObject() / TerminateProcess()


Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
difference between String.subString() and String.subSequence() 6 236
matchUp  challenge 6 69
wordcount challenge 11 133
Excel file not created as expected 7 79
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question