?
Solved

Unistall MFC app - Need to cleanup registry on uninstall

Posted on 2009-07-02
13
Medium Priority
?
532 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +2
13 Comments
 
LVL 24

Assisted Solution

by:alexey_gusev
alexey_gusev earned 200 total points
ID: 24764896
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
ID: 24764943
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
ID: 24764963
from my side - no, I don't know if there is something else
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Author Comment

by:mrjoltcola
ID: 24764972
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
ID: 24765008
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 1600 total points
ID: 24765011
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
 
LVL 40

Author Comment

by:mrjoltcola
ID: 24765040
>>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 200 total points
ID: 24765050
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 1600 total points
ID: 24765106
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
ID: 24771462
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
ID: 24773399
>>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
ID: 24773429
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
ID: 24773787
>>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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
A short article about problems I had with the new location API and permissions in Marshmallow
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 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