Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

How do I Launch Windows Aps from Other Windows Aps?

How do I launch Windows applications from other Windows applications or does anyone know a book that might have this information.  Also can there is exist some "simple" communication?
0
bfrench
Asked:
bfrench
1 Solution
 
t004024Commented:
To launch another application from one Windows application U can use ShellExecute or WinExec functions.
0
 
galkinCommented:
CreateProcess is preffered.
0
 
karauCommented:
galkin is correct, use CreateProcess.  Here is a copy of the code
that I used in my app to do this:


 int len = MyPopClass.PFile.GetLength()+1;
 char* str = new char[len];
 lstrcpy(str, m_PFile);
 if(!CreateProcess(NULL,str,NULL,NULL,FALSE,0,NULL,NULL,&start,&proc))
   AfxMessageBox("Unable to Launch Program",MB_OK|MB_ICONSTOP);

in this example MyPopClass.PFile is a CString and the code between that and the CreateProcess is used to convert it to a char that CreateProcess needs.  As I recall the first parameter set to NULL is the pointer to the parent (CWnd *), but the other ones you would have to look up under Help.

j. karau
0
 
karauCommented:
I also forgot to include the fact that start and proc are global variables that are declared as follows:

STARTUPINFO      start;
PROCESS_INFORMATION proc;
0
 
YKuniskyCommented:
I agree that Galkin gave correct answer to use  function
"CreateProcess"
I  wish to advice a book "Advanced Visual C++ 5"
Steven Holzner ISBN 1-55851-565-8 which
has an examples of codes in chapter 7.
For example,how to call MS calculator from your application
using Windows hooks.
I think there is a good decision  to exchange data between
to applications using pipes.
0

Featured Post

Industry Leaders: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now