954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ create process function not working

hi, i am making a program that kills a process

system("taskkill /im explorer.exe");

and i need to restart the process using CreateProcess.

CreateProcess(NULL,("C:\\WINDOWS\\explorer.exe"), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &siStartupInfo, &piProcessInfo);

but i keep getting these errors: 27 `siStartupInfo' undeclared (first use this function) and 27 `piProcessInfo' undeclared (first use this function)

any solutions?

thecoolman5
Posting Whiz in Training
234 posts since Dec 2010
Reputation Points: 18
Solved Threads: 1
 

Did you declare siStartupInfo and piProcessInfo?
If so, where in the program did you delcare them?

thines01
Postaholic
Team Colleague
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
 

No I didn't declare them.

thecoolman5
Posting Whiz in Training
234 posts since Dec 2010
Reputation Points: 18
Solved Threads: 1
 
STARTUPINFO siStartupInfo = {0};
siStartupInfo.cb = sizeof sif;
siStartupInfo.dwFlags = STARTF_USESHOWWINDOW;
siStartupInfo.wShowWindow = SW_NORMAL;
PROCESS_INFORMATION piProcessInfo = {0};


And an alternate method is recommended by using ShellExecute/ShellExecuted if you don't want to manipulate the new process.

jinhao
Newbie Poster
14 posts since Dec 2008
Reputation Points: 25
Solved Threads: 5
 

Ok that got it wirking. Thanks for your help

thecoolman5
Posting Whiz in Training
234 posts since Dec 2010
Reputation Points: 18
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: