Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CreateProcess function

Posted on 2000-03-23
6
Medium Priority
?
243 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

604 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