Solved

CreateProcess function

Posted on 2000-03-23
6
239 Views
Last Modified: 2010-04-02
I have an MFC application and I need
to run another process (wich is console application) from it, I have an Acces Violation error.
Here is the code
CreateProcess("S:\Version1\TempControl\Debug\TempControl.exe", NULL, NULL, NULL, FALSE,
            0,NULL,NULL,NULL, NULL)


Thanks
0
Comment
Question by:Yulia
  • 3
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
MDarling earned 30 total points
ID: 2650120
This is beacuse you have failed to provide the PROCESSINFORMATION and STARTUP_INFO structures.  Do this...

    STARTUPINFO SI;
    PROCESS_INFORMATION PI;
    ZeroMemory(&SI,sizeof(STARTUPINFO));
    SI.cb=sizeof(STARTUPINFO);
CreateProcess(0,"myapp.exe",0,0,0,0,0,0,&SI,&PI);

and all should be well.

regards,
Mike.


0
 
LVL 3

Expert Comment

by:MDarling
ID: 2650125
after the call, if you don't need the handles for anything you should do this...


        // be nice and give NT back it's resources
        CloseHandle(PI.hProcess);
        CloseHandle(PI.hThread);


regards,
Mike.
0
 

Author Comment

by:Yulia
ID: 2650183
Thanks Mike, just one little problem,
when I write a full psth for application:
"S:\Version1\TempControl\Debug\TempControl.exe"

the compiler doesn't like "\"

Thanks anyway
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Expert Comment

by:Wyn
ID: 2654144
Yulia ,try \\ ,\ is escape directive in C++
"S:\\Version1\\TempControl\\Debug\\TempControl.exe"

Regards
W.Yinan
0
 
LVL 3

Expert Comment

by:MDarling
ID: 2663292
Wyn's right,

you need double slashes in C/C++ because
as he says '\' is an escape character.

regards,
Mike.
0
 

Author Comment

by:Yulia
ID: 2663453
Thanks, it's working
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

789 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