Solved

restarting a program from itself

Posted on 1999-01-20
4
223 Views
Last Modified: 2010-05-18
After the user finishes with the program I write, I want the program to restart automatically (it starts in a 'sleep' mode).
What is the best way to restart the program from it's own end?
Thanks.
0
Comment
Question by:gilbert_chang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

by:Trickster
ID: 1184574
Is there any reason why you can't just include the main-code in a while-loop? For example using

int looping = 0;
while (looping == 0)
{
    PROGRAM!
    if (userWantsToQuit)
        looping = 1;
}

I often use a Timer which runs the program when I want the program to restart after a set number of seconds..

Trickster
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 50 total points
ID: 1184575
At the end of your programm use something like

_spawnl( _P_NOWAIT, lpszAppFullPath, lpszAppFullPath, NULL );

hope that helps,

ZOPPO
0
 

Author Comment

by:gilbert_chang
ID: 1184576
Trickster - what about threads and other memory structures I created in the program.
Trying to start them over might cuase explosions...right?
Thanks.
0
 

Author Comment

by:gilbert_chang
ID: 1184577
Thanks Zoppo!
This works.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question