-
CreateProcess
I would like to use CreateProcess to start an app minimised but I just can't get it to work.
As a test, I set up the CreateProcess parameters and STARTUPINFO structure with the following lines;
STARTUPINFO suInfo;
PROCESS_INFORMATION procInfo;
CString m_Process = "C:\\WINDOWS\\NOTEPAD.EXE";
char *vip = "C:\\WINDOWS\\NOTEPAD.EXE";
memset(&suInfo, 0, sizeof(suInfo));
suInfo.cb = sizeof(suInfo);
suInfo.dwFlags = STARTF_USESHOWWINDOW;
suInfo.wShowWindow = SW_MINIMIZE;
And then on the press of a key, I called the CreateProcess thus;
CreateProcess(m_Process,vip,NULL,NULL,FALSE,NORMAL
_PRIORITY_CLASS,NULL,NULL,&suInfo,&procInfo);
I thought this code would start notepad minimised but it starts as a normal window... any ideas on what is wrong?
-
Personally, if I have to do this sort of thing I will go for ShellExecute....its easier and is more than sufficient for this sort of deal;
Code:
ShellExecute(HWND_DESKTOP,"OPEN","NOTEPAD",NULL,
NULL,SW_SHOWMINIMIZED);
Nothing easier!!!!
CreateProcess is much more complicated and allows greater power (IE....security and how the process is created - such as with a console....), but for this stuff......no need to get complex :cool:
-
I considered ShellExecute but as you say, CreateProcess is more powerful. I am trying to use CreateProcess so that I then get the information required to kill the process whenever I want.
All I need is a hint on what I am doing wrong in setting up the call.
-
Thanks for tryin but looks like I've figured it out now :)
The first two arguments of CreateProcess are Application Name and Command Line. By setting the above Command Line value to NULL (ie replacing the 'vip' with NULL), the example now works.