CreateProcess to start, suspend and continue a program
Posted on 2005-04-23
I am working on a CDialog based application which automates
a program I am using extensively. Since the programm running
eats all the resources and it might run for days and days at a time,
I want to be able to suspend it and of course after I am done whatever
I did i want to continue at the point I left of.
It would also be fine to set the processing priority to very very low so
that everything else works alongside with the program.
Here is the call I am using at the moment:
ZeroMemory (&sei, sizeof (SHELLEXECUTEINFO));
sei.cbSize = sizeof (SHELLEXECUTEINFO);
sei.lpFile = javaLoc; //Full path to java.exe
sei.lpVerb = "OPEN";
sei.lpDirectory = workDir.c_str();
CString pars = "";
//All paths are full paths except for paths in the worDir (peaks.jar, tmp.xml)
pars.Format(" -Xmx%dM -jar %s %s %s %s %s \"%s\" %f %f %d %d",
sei.lpParameters = pars;
//Don't show the console with the raw file extraction, only disturbs everybody
sei.nShow = SW_NORMAL;
sei.nShow = SW_HIDE;
//Return here when done and don't display any errors while your at it.
sei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
int ret = GetExitCodeProcess(sei.hProcess, &dwCode);
How can I control this process from a button in the dialog?
I guess I have to switch to CreateProcess, right?
Or is the process above already encapsulated in a thread that I can suspend and continue?