Solved

CreateProcess function

Posted on 2000-03-23
6
236 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 5

Expert Comment

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

Regards
W.Yinan
0
 
LVL 3

Expert Comment

by:MDarling
Comment Utility
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
Comment Utility
Thanks, it's working
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
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 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.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

744 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

10 Experts available now in Live!

Get 1:1 Help Now