DtActivate can help reuse existing app instances so that no more than one instance of an application is running. Note that Multiple instances are sill possible if the user launches DtActivate several times in the blink of an eye
This program was previously called just "Activate". It was renamed because Windows XP has a command named "Activate".
DtActivate contains two executables. They provide the same capability, but one may be more appropriate for each situation.
Use DtActivate.exe when launching a console application because it is a console mode application.
Use DtActivateW.exe when launching a non-console (windowed or windowless) application because it is a windowless application.
For DtActivate to work with a program, the window must have a known title prefix that is unique to that application. DtActivate matches the beginning of the title, so it is OK if an app changes the end the title (e.g. to indicate what file you are working with). For DOS/Console applications you can edit the icon properties and set the title. If a batch file is launched, you may use the “Title” command in that batch file.
After the title is set up properly, DtActivate needs to be involved in the application launch. Here are some ways to do that.
For a Dos App, have DtActivate launch the pif.
For a batch file, use errorlevel from DtActivate to control batch execution
For a win32 app, have DtActivate launch the app
DtActivate may be useful in a batch file because it returns an errorlevel that may be useful. Here are the values:
0 – The app is not running and you did not specify a command line to run
1 - The app is already running and focus was moved to it.
2 - The app is not running and DtActivate attempted to start it. This is the errorlevel regardless of whether the attempt succeeds.
See the Sample.zip file for the files that are associated with following examples.
If your app is a DOS app it is probably launched using a PIF file. Note that explorer does not show the .pif extension – but you may se it by listing the file from a cmd prompt.
For example, you run a DOS app using “c:\Documents and Settings\User\Desktop\MyApp.Pif”. The following steps will make sure only one copy of the app is running
1. Edit MyDosApp.pif and set the title to a known value - perhaps to: “ MyDosApp - thanks to DtActivate”
2. Set the file attributes of MyDosApp.pif so that it is hidden, and/or move it to a location where it is not easily visible.
3. Create a shortcut. Specify “DtActivate.exe MyDosApp MyDosApp.pif” as the command line. Remember – no spaces in paths or file names….
The new icon should launch the app the first time it is run, and activate it on subsequent times.
An example MyDosApp is provided. To work as-is, this needs to expand to the root of the C: drive, so that the files will be in a folder named C:\MyDosApp.
See the MyWinApp sample