Posted By

jimfred on 02/18/09


Tagged


Versions (?)

Add self-uninstall ability to MFC application by calling ShellExecute for MsiExec.exe


 / Published in: C++
 

URL: mfc uninstall

Add self-uninstall ability to MFC application by calling ShellExecute for MsiExec.exe. Useful for temporary apps that can be uninstalled after use. The installation's GUID is required. This GUID is auto-created by Visual Studio when a Setup/installation project is created.

  1. BOOL MyDlg::OnMenuUninstall( UINT nID )
  2. {
  3. // WinExec is obsolete.
  4.  
  5. ShellExecute(
  6. NULL, // hwnd
  7. "open", // operation/verb.
  8. "MsiExec.exe", // executable.
  9. "/x{FEF094C3-B58A-42e5-8170-659A670B25E6}", // parameters.
  10. "", // directory
  11. SW_SHOW ); // how to be displayed
  12.  
  13. // GUID comes from setup.vdproj file. Search for...
  14. // "ProductName" = "8:DCT Upgrade"
  15. // "ProductCode" = "8:{FEF094C3-B58A-42e5-8170-659A670B25E6}"
  16. return TRUE;
  17. }

Report this snippet  

You need to login to post a comment.