Click here to Skip to main content
15,885,985 members
Articles / Desktop Programming / WTL

How To Create a Self-Restartable Application

Rate me:
Please Sign up or sign in to vote.
4.71/5 (29 votes)
21 Aug 2006CPOL3 min read 112.3K   4.6K   122  
This article describes the way to add restarting support to your Win32 applications.
#pragma once

// Command line switch for restarted application
#ifndef RA_CMDLINE_RESTART_PROCESS
	#define RA_CMDLINE_RESTART_PROCESS	TEXT("--Restart")
#endif

// Mutex unique name
#ifndef RA_MUTEX_OTHER_RESTARTING
	#define RA_MUTEX_OTHER_RESTARTING	TEXT("YOUR_RESTART-MUTEX_NAME")
#endif

// Return TRUE if Process was restarted
BOOL RA_CheckProcessWasRestarted();

// Check process command line for restart switch
// Call this function to check that is restarted instance
BOOL RA_CheckForRestartProcessStart();

// Wait till previous instance of process finish
BOOL RA_WaitForPreviousProcessFinish();

// Call it when process finish
BOOL RA_DoRestartProcessFinish();

// Call this function when you need restart application
// After call you must close an active instance of your application
BOOL RA_ActivateRestartProcess();

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions