QA: How can I add my custom function to installation/uninstallation?
Vassili Philippov (vasja@spbteam.com), November 19, 2002.
Question
I need to do some custom actions (run a file, refresh Today screen, check serial number, etc)
during Pocket PC program installation. How can I do it?
Answer
It is often when you have to do custom actions that cannot be done by the standard
CAB file described in INF file. In that case you have to use a Setup.dll. It is a DLL
that exports 4 functions:
- Install_Init
- Install_Exit
- Uninstall_Init
- Uninstall_Exit
These 4 functions are called by the framework before installation, after installation, before
uninstallation and after uninstallation corresponding.
You can find signature of these 4 functions and information about the parameters and the
return value in Pocket PC SDK help.
Typical situations when you need custom actions during installation/uninstallation are:
- Refresh of the Today screen when you install a Today plug-in
- Starting your application if it should work as a background process
- Displaying an installation wizard
- Backup some registry settings that you are going to overwrite
- Deleting temporary files/registry values that are not deleted automatically
- Install different CAB files for ARM and XScale CPUs
INF file
To include your setup.dll in the INF file (file used to build installation CAB file) you
have to add the following string:
CESetupDLL = "Setup.dll"
To the [DefaultInstall] section.
Create Setup.dll step-by-step
- Create new WCE MFC AppWizard (dll) project in eVC++
- Accept default settings and press the Finish button
- Open .def file (your will find it in the FileView tab of the Workspace
- Add information about the following 4 export functions:
EXPORTS
Install_Init
Install_Exit
Uninstall_Init
Uninstall_Exit
- Copy ce_setup.h file from Pocket PC 2002 SDK include folder to your
project folder. This file is not included in Pocket PC 2002 include folder and
to make your project compilable under both 2002 and 2000 platforms it is better
to have a local copy of this file.
- Add including of ce_setup.h file to your .cpp file:
#include "ce_setup.h"
- Add the following 4 functions to the end of your .cpp file:
codeINSTALL_INIT
Install_Init(
HWND hwndParent,
BOOL fFirstCall,
BOOL fPreviouslyInstalled,
LPCTSTR pszInstallDir
)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return codeINSTALL_INIT_CONTINUE;
}
codeINSTALL_EXIT
Install_Exit(
HWND hwndParent,
LPCTSTR pszInstallDir,
WORD cFailedDirs,
WORD cFailedFiles,
WORD cFailedRegKeys,
WORD cFailedRegVals,
WORD cFailedShortcuts
)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return codeINSTALL_EXIT_DONE;
}
codeUNINSTALL_INIT
Uninstall_Init(
HWND hwndParent,
LPCTSTR pszInstallDir
)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return codeUNINSTALL_INIT_CONTINUE;
}
codeUNINSTALL_EXIT
Uninstall_Exit(
HWND hwndParent
)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return codeUNINSTALL_EXIT_DONE;
}
Related resources:
-
http://www.pocketpcdn.com/sections/installation.html
Section: Installation
-
http://www.pocketpcdn.com/articles/ezsetup.html
Article: Using EzSetup for creating Pocket PC installations
-
http://www.pocketpcdn.com/articles/airsetup.html
Article: Using Spb AirSetup to create Pocket PC installers
-
http://www.pocketpcdn.com/articles/multicabinstall.html
Article: Installing multiple CAB files with the same setup application
-
http://www.pocketpcdn.com/articles/uninstall.html
QA: How to uninstall a Pocket PC application?
-
http://www.pocketpcdn.com/articles/creatingsetup.html
QA: How can I create setup.exe file that will automatically install necessart .cab file on Pocket PC?
-
http://www.pocketpcdn.com/articles/installcab.html
QA: How to install a cab file on Pocket PC?
- http://www.microsoft.com/mobile/developer/technicalarticles/installation.asp
Article: Successful Installation for Pocket PC Applications
- http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnce30/html/appinstall30.asp
Article: Creating an Application Installation Package with Microsoft Windows CE 3.0
- http://www.innovativedss.com/pdfs/installmaster.pdf
Article: Deploying Windows CE applications with Wise InstallMaster
- http://www.devbuzz.com/content/zinc_PPCInstall_pg1.asp
Article: deVBuzz speaks with Jeff Law of PPCInstall