Click here to Skip to main content
13,258,926 members (46,759 online)
Click here to Skip to main content
Add your own
alternative version


41 bookmarked
Posted 16 Feb 2000

Two Simple Lines for Self-Repairing Apps

, 16 Feb 2000
Rate this:
Please Sign up or sign in to vote.
Creating Self-Repairing Applications using Windows Installer


Ever wondered how MS Office 2000 repairs itself if any files are corrupted or missing? Just two lines of code can add this feature to your app.

First off, you must create an installer program from Windows Installer (free for Visual Studio 6.0 or VC++ 6.0 customers). The self-repairing services are provided via the Windows Installer system. If you are not developing for Windows 2000 only, make sure to set the project settings so that the Setup.exe file will install Windows Installer on the system if it is not already present (Windows Installer comes with Windows 2000, but is not included with previous versions of Windows).

Once your program is installed, it can verify and reinstall needed components with the following two lines.


To compile, you will need to link your product with the installer library (msi.lib) and include the installer header msi.h.

Make sure to replace the product ID with the product ID that is in the settings dialog for your program. This is needed by Windows Installer. Additionally, the first line is not required. However, it will hide the GUI from the user (without it, a Windows installer dialog will appear). Other settings are:

// Authored user interface with wizards, progress, and errors.
// Authored user interface with wizard dialog boxes suppressed.
// Simple progress and error handling.
// The installer chooses an appropriate user interface level.
// The installation level is not changed.
// Completely silent installation.

For the reinstall function, possible options are:

// Repair any defects encountered.
// Reinstall only if the file is missing.
// Reinstall if the file is missing or is an older version.
// Reinstall if the file is missing or is an equal or older version.
// Reinstall if the file is missing or is not an exact version.
// Check sum executables, and reinstall if they are missing or corrupt.
// Reinstall all the files regardless of version.
// Ensure required user regular entries.
// Ensure required machine regular entries.
// Validate shortcuts and progman items.

That's it!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Jesse Ezell
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralTamper Aware and Self Healing Code Pin
Jeffrey Walton28-May-07 21:25
memberJeffrey Walton28-May-07 21:25 
QuestionHow to disable the self-repair? Pin
joanne_fredrickson28-Oct-03 16:16
memberjoanne_fredrickson28-Oct-03 16:16 
AnswerRe: How to disable the self-repair? Pin
Yogurt9-Mar-04 7:22
memberYogurt9-Mar-04 7:22 
GeneralRe: How to disable the self-repair? Pin
matzy11-Nov-04 9:30
membermatzy11-Nov-04 9:30 
GeneralRe: How to disable the self-repair? Pin
Guerven11-Jun-07 0:16
memberGuerven11-Jun-07 0:16 
GeneralUseful Pin
Armen Hakobyan8-Jun-02 4:17
memberArmen Hakobyan8-Jun-02 4:17 
GeneralUnclear Pin
Hongwei Jia26-Feb-01 11:20
memberHongwei Jia26-Feb-01 11:20 
GeneralRe: Unclear Pin
lauren26-Feb-01 11:46
memberlauren26-Feb-01 11:46 
looking at the code lines and the comment "link with ...." it appears to me to be in your app that you put the code ... i would assume putting them in the InitInstance() function of the CMainFrame() class would be the correct way but shoot me if i'm wrong
Smile | :)

"every year we invent better idiot proof systems and every year they invent better idiots"
GeneralRe: Unclear Pin
Hongwei27-Feb-01 5:12
memberHongwei27-Feb-01 5:12 
Generalunclear about implementation.... Pin
Jeff Douglas2-Feb-01 5:33
memberJeff Douglas2-Feb-01 5:33 
QuestionHow to implement this code? Pin
Jeff Thompson10-Jan-01 7:57
memberJeff Thompson10-Jan-01 7:57 
GeneralNote on Error Handling Pin
Jesse Ezell17-Feb-00 4:48
suss Jesse Ezell17-Feb-00 4:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 17 Feb 2000
Article Copyright 2000 by Jesse Ezell
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid