Solved

Unistall MFC app - Need to cleanup registry on uninstall

Posted on 2009-07-02
13
522 Views
Last Modified: 2013-12-27
One of my Win32/MFC apps stores some config data in the registry, but this is done during the first application run (after the install from the cab). So when I remove by normal Uninstall or Remove Programs, the registry values stay. My app creates the values using SetRegistryKey(_T("mycompany")) plus the standard Read/WriteProfile* methods.

What are my options? I do not want a special utility or function for the user to use, I want it automated for cleanup.

I guess I could create the registry settings in the installer somehow, would that then cause the settings to also be removed?

I am using Visual Studio 2008 and the standard Smart Device Cab project. Windows Mobile 5 and 6.

Looking for some specifics here, not vague direction.
0
Comment
Question by:mrjoltcola
  • 5
  • 3
  • 3
  • +2
13 Comments
 
LVL 24

Assisted Solution

by:alexey_gusev
alexey_gusev earned 50 total points
Comment Utility
create Setup.dll which is called on Install/Uninstall, specify it during cab creation and cleanup whatever you want
0
 
LVL 40

Author Comment

by:mrjoltcola
Comment Utility
Ok, I was aware of that option but thought if I used a certain naming convention perhaps, that the registry keys could be automated without the DLL.

So there is no other non-code option that you are aware of?
0
 
LVL 24

Expert Comment

by:alexey_gusev
Comment Utility
from my side - no, I don't know if there is something else
0
 
LVL 40

Author Comment

by:mrjoltcola
Comment Utility
Ok, well I trust you better than myself in this area, so I'll proceed with the setup.dll

Thanks!
0
 
LVL 24

Expert Comment

by:alexey_gusev
Comment Utility
I believe Setup.dll way is cleaner because it gives you more control over what's happening dusing the install/uninstall. MFC might be smart, but it's too often TOO smart :)
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 400 total points
Comment Utility
Why not create the keys and values from your installer (with dummy values) so it will remove then when you hit the uninstall button?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 40

Author Comment

by:mrjoltcola
Comment Utility
>>Why not create the keys and values from your installer (with dummy values) so it will remove then when you hit the uninstall button?

That's what I am asking. If I put them into my cab project, they'll be deleted on uninstall, correct?

I know it may seem a simple question, I can surely test myself but I use EE to save me some time. :)
0
 
LVL 33

Assisted Solution

by:pgnatyuk
pgnatyuk earned 50 total points
Comment Utility
You can try to add the registry keys from the cab and not from the app. It is easy if you have a cab-manager. You can do it in the inf-file manually also. I never tried to manage the cab-file in the studio - maybe it also works.
If your app adds more keys and values - probably, the same as new files and folders, they will be in the registry after the uninstallation.
setupdll is the official way to make such changes.
 
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 400 total points
Comment Utility
My experience of a commercial installer (Wise for windows) is that it does remove any registry keys that it created when an uninstall is performed.
I believe that all installers 'authorised' for use in windows should behave the same way.

However they will not remove keys if there are subkeys/values created by your app.
0
 
LVL 2

Expert Comment

by:softbee
Comment Utility
I must assume that the exact info is known when the app is deployed, since it is included in the cab.
If the cab includes a .ini file and you work through this instead of the actual registry, then the .ini file can be wiped by the uninstaller as easily as it was created. A dll for such a triviality is an overkill?.Nothing to do with MFC.
If we are going to talk MFC then 'theApp'->InitInstance can do the instantiation and 'theApp'->ExitInstance can get rid of it.
My instinct tells me to use the registry for those items that change during the program lifespan.
Nowadays with side-by-side programming you dont even have to worry where to find the info X.ini file anymore..
Andy is right when he says that programs such as Wise or NSIS will look after your problem admirably and both have a full set of instructions to deal with the registry.
0
 
LVL 40

Author Comment

by:mrjoltcola
Comment Utility
>>I must assume that the exact info is known when the app is deployed, since it is included in the cab.

No, the info is not known at install. It is created through the installation procedure which includes license key, encryption keys, remote synchronization and data download. User's also select preferences during that step, but those are not critical keys.

I didn't say it had anything specifically to do with MFC, but it is relevant to my question, since it is an MFC app.

Your point about the .ini file being user to maintain is a good one, but one that we are familiar with. It's a balance.

1) The users of my product can get click happy and fiddle with the settings and/or delete files. I've found the registry works well for this as it is more hidden from the user. Yes, not impossible, but its not meant to be a bulletproof method, just a crowd-control method. When I've a customer on the line and we don't know what their problem is, we can say, select this directory and delete it, then re-run the update utility. All of the user's customizations are safe during that procedure. The 1st generation app did use an ini file and we would have to tell the user "don't delete the ini file" during the procedure.

2) For security reasons I want to more strongly tie the user to a specific piece of hardware (PDA, Laptop) due to the nature of the data stored in the application. Storing certain keys in the registry discourages people from copying files to move their identity. There are security reasons for this application, so the less transparent that is, the better. Again, not 100% bulletproof but works.

But really, I don't want to get into a debate over ini file vs registry, that was not my question.


>>Nowadays with side-by-side programming you dont even have to worry where to find the info X.ini file anymore..

The programming style has no relevance to maintaining a production application in the hands of customers. My users are not the programmers. I'm talking about making the app a bit harder to both intentionally or unintentionally tamper with, for the average user.

0
 
LVL 40

Author Comment

by:mrjoltcola
Comment Utility
To the original topic, if I put the keys both in the CAB, and then set them in the setup procedure, managing a full set of keys in both the CAB installer and the software setup required me to keep them in sync. I'd prefer to maintain them in one place. I really don't like the idea of the separate setup.dll but I like less having 2 places to change when modify the keys.

I have the setup.dll created, it did not take long.

I guess the main part of my question was answered, if I create dependent keys, then the parent keys wont be removed by the CAB uninstall. I did not test this, but I will trust AndyAinscow on this until I do get a chance to test it, since he's always given good advice.

Thanks guys.
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
>>I will trust AndyAinscow on this until I do get a chance to test it, since he's always given good advice.

Thanks, I try to do so.  Should it prove incorrect then let me know, I'm always willing to learn.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

One of the most frequently asked questions on EE in the "Windows Installer" zone is how to eliminate self-triggered installation of some product.  The problem occurs when, suddenly, whenever a certain application is launched, or even when a folder i…
If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now