Solved

eVC: Starting other app and writing a file

Posted on 2006-10-19
10
162 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
Comment Utility
>>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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

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

Expert Comment

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Importing  SSL Certificate into Firefox using GPO 28 192
countEvens challenge 2 56
pre4 challenge 19 87
wordcount challenge 11 72
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now