Thread: Help to skip a process

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    Help to skip a process

    I'm working on a project that plays a song, but I want the user to have the option to skip the song if they do not want to hear it. The only way that I know to end a process is to hit ctr-c, which of course kills the whole program. The code that I have to start the song is below...

    Code:
    int Header::Call()
    {
    	PlaySound("Daylight.wav", NULL, SND_FILENAME|SND_LOOP);
    }
    I have searched for hours and cannot find anything that helps. I'm using Dev++. Any help would be appreciated. Thanks in advance.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Look at the options for PlaySound().

    In the options for the third argument, there is SND_ASYNC which plays the sound assynchronously, and returns control to your program. All you then need to do is check for termination conditions (eg if the user has hit CTRL-C, if that's what you're using) and call PlaySound() with the first argument NULL - that terminates any playing sound.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help fast
    By blackice in forum C Programming
    Replies: 2
    Last Post: 01-31-2011, 01:19 PM
  2. Why isn't the execlp() function doing anything?
    By jsrig88 in forum C Programming
    Replies: 5
    Last Post: 10-12-2009, 10:09 AM
  3. sequenceing or queueing multiple process
    By sv_joshi_pune in forum Windows Programming
    Replies: 1
    Last Post: 08-14-2009, 09:43 AM
  4. Problem with forking a process
    By Unitedroad in forum C Programming
    Replies: 10
    Last Post: 10-04-2007, 01:43 AM
  5. process programming
    By St0rM-MaN in forum Linux Programming
    Replies: 2
    Last Post: 09-15-2007, 07:53 AM