Jump to content
  • Advertisement
Sign in to follow this  
homeboye

background process?

This topic is 4523 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, i'd like to know if there is something similar as CreateProcess()? I was thinking more in external libraries(as SDL or such). If nothing else, i'd like some links to good tutorials/examples of CreateProcess(). ty

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by homeboye
okay, but now that i've created a new process, how do i execute something(for instance, defrag.exe /f)?

// get system settings to create new process
STARTUPINFO info;
GetStartupInfo( &info );

// process info struct to get info
PROCESS_INFORMATION pinfo;

// launch process
CreateProcess( NULL, // module name (unused)
"defrag.exe /f", // command line
NULL, // process attributes
NULL, // thread attributes
FALSE, // inherits handle?
NORMAL_PRIORITY_CLASS, // thread priority
NULL, // environment
NULL, // current directory
&info, // startup info
&pinfo // process info
);


Note that the command-line argument is automagically executed when you call the function.

Share this post


Link to post
Share on other sites
ShellExecute(HWND(), char(), "defrag", "-f c:", char(), SW_NORMAL);

Shorter, no? - Though of course, with CreateProcess you get more options, but if you're just looking for something simple, I guess ShellExecute will suit you just fine.

Share this post


Link to post
Share on other sites
Quote:
Original post by raz0r
ShellExecute(HWND(), char(), "defrag", "-f c:", char(), SW_NORMAL);

Shorter, no?

Just to satisfy my own curiosity (because MSDN isn't exactly that descriptive); but does that execute defrag in a separate process? (ie, would the above call block until the disk was defragged?) I guess the choice of function, inevitably, comes down to the desired usage.

EDIT (in response to the response to this post because I'm too lazy to make a new post): Hooray!

Share this post


Link to post
Share on other sites
Quote:

Just to satisfy my own curiosity (because MSDN isn't exactly that descriptive); but does that execute defrag in a separate process?

Of course.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!