Solved

CreateProcess function

Posted on 2000-03-23
6
237 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now