Solved

eVC: Starting other app and writing a file

Posted on 2006-10-19
10
168 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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