?
Solved

CreateProcess function

Posted on 2000-03-23
6
Medium Priority
?
242 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
MDarling earned 120 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
Independent Software Vendors: 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!

 
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.
Suggested Courses

762 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