News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

QA: How can I add my custom function to installation/uninstallation?

By Vassili Philippov, November 19, 2002.
Print version

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

  1. Create new WCE MFC AppWizard (dll) project in eVC++
  2. Accept default settings and press the Finish button
  3. Open .def file (your will find it in the FileView tab of the Workspace
  4. Add information about the following 4 export functions: EXPORTS Install_Init Install_Exit Uninstall_Init Uninstall_Exit
  5. 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.
  6. Add including of ce_setup.h file to your .cpp file: #include "ce_setup.h"
  7. 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:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House