Solved

eVC: Starting other app and writing a file

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

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:

Start
executing another application
writing a string "done" to a file in the same directory as the application
is
exiting...

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
thankful!

Sven
0
Comment
Question by:Ruttensoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
10 Comments
 
LVL 22

Expert Comment

by:mahesh1402
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

        PROCESS_INFORMATION pi;
        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 );
        CloseHandle(pi.hProcess);


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

-MAHESH
0
 

Author Comment

by:Ruttensoft
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++...

Thanks
0
 
LVL 22

Accepted Solution

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

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

For more have a look at :
INFO: Understanding CreateProcess and Command-line Arguments :http://support.microsoft.com/kb/175986

-MAHESH
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

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

Expert Comment

by:mahesh1402
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

e.g

TerminateProcess(pi.hProcess,-1);

-MAHESH
0
 

Author Comment

by:Ruttensoft
ID: 17764014
Hi

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
0
 
LVL 22

Expert Comment

by:mahesh1402
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()

-MAHESH
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tab names are off by one 5 54
windows 10 how make picture as desktop background 2 66
zeroMAx challenge 20 125
Problem to event 3 112
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

735 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