Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to call .exe (DSP to DAA conversion executive) on button clicked event

how i can pass text file as an input to .exe file

In text file contain list of .DSP file names which needs to be convert from .DSP to .DAA files

whenever i called .exe on button clicked it should asks to enter text file name.

is there any other method (than ShellExecute)to call exe file in the mfc vc++.

Thank you
Posted
Comments
Sergey Alexandrovich Kryukov 25-Mar-13 16:12pm    
.EXE cannot be "called", it's not a function, method, procedure, subroutine, property or operator.
—SA
Maximilien 25-Mar-13 16:15pm    
Well, an EXE can be "called" with ShellExecuteEx or "system".
Sergey Alexandrovich Kryukov 25-Mar-13 16:27pm    
Only in big quotation marks. It's really important to understand the difference of real call from everything else. Starting of an application is very different from a "call". Actually, the first real "call" is the call of a main function, and a lot more things are happened before. By all measures, an application is not really called; it is loaded (quite a complex OS operation) and executed.
—SA
peoria123 25-Mar-13 16:15pm    
sorry.. I mean to run .exe on button clicked event in the mfc
[no name] 25-Mar-13 18:30pm    
The bigger question is why are you posting questions that you already know the answer to?

Use ShellExecute[^], ShellExecuteEx[^], system[^] to call your EXE.
 
Share this answer
 
You can start an application by the name of its *.EXE file using the function CreateProcess, ShellExecute or ShellExecuteEx:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762154%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx[^].

You can pass anything to the process you are starting only if the application is designed to accept this data: file name or anything at all. Usually, good application can accept and handle command line parameters. When you start an application, you can always specify some command line parameters, which is documented in the MSDN help articles referenced above.

If you need to pass some file name to be requested from the user; and it is not done in the application your are starting, you should request the file in your UI using the standard MFC file dialog and then pass it to the application (if it is designed to accept it, of course). Please see:
http://msdn.microsoft.com/en-us/library/dk77e5e7%28v=vs.71%29.aspx[^].

You application should be responsible for preparation of the file, file conversion, proper file type and everything like that. The accepting and processing of the file depends on how the application you start works.

That said, it's always bad to rely on some application which is not a part of your solution. You always have very limited control over such application. If you have the source code of this application which you can support, it's much advised to convert it to a DLL for in-proc use; this way you would gain a full control.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900