Page 1 of 1

Add your uninstaller to add/remove programs.

Posted: Thu Sep 22, 2005 12:15 pm
by DoubleDutch
Code updated For 5.20+

I've just added this to SpyMon and ReportBuilder, thought I may as well share it... :D

Code: Select all

Procedure SetUninstall(name$,pub$,url$,email$,telno$,dicon$,uexe$)
	ukey=0
	If RegCreateKey_(#HKEY_LOCAL_MACHINE,"Software\Microsoft\Windows\CurrentVersion\Uninstall\"+name$,@ukey)=0
		RegSetValueEx_(uKey,"DisplayName",0,#REG_SZ,@name$,Len(name$)+1)
		RegSetValueEx_(uKey,"DisplayIcon",0,#REG_SZ,@dicon$,Len(dicon$)+1)
		RegSetValueEx_(uKey,"Publisher",0,#REG_SZ,@pub$,Len(pub$)+1)
		RegSetValueEx_(uKey,"URLInfoAbout",0,#REG_SZ,@url$,Len(url$)+1)
		RegSetValueEx_(uKey,"HelpLink",0,#REG_SZ,@url$,Len(url$)+1)
		RegSetValueEx_(uKey,"Contact",0,#REG_SZ,@email$,Len(email$)+1)
		RegSetValueEx_(uKey,"HelpTelephone",0,#REG_SZ,@telno$,Len(telno$)+1)
		RegSetValueEx_(uKey,"UninstallString",0,#REG_SZ,@uexe$,Len(uexe$)+1)
		RegCloseKey_(uKey)
	EndIf
EndProcedure 
Its fairly easy to use, here is an example:

Code: Select all

SetUninstall("ReportBuilder","Apple Panic Limited","http://www.ApplePanic.com","office@ApplePanic.com","+44(0)870 xx xxxx",AppFilename$,SetupDir$+"\UnInstall.exe")
You need to include full paths in your uninstall apps as the working directory usually isn't the same place as the actual uninstall program.

I just point to the original application that was installed for an icon, it seems to work okay.

Your uninstall program should delete the registry key as it finishes (to take it out of add/remove programs).

Posted: Tue Sep 27, 2005 7:00 pm
by josku_x
Coool! I never came up that the Add/Remove thing in Control Panel uses Registry?!?!?!?!

That's cool example :D

Posted: Wed Sep 28, 2005 2:49 pm
by Rescator
You can store other info along with it as well.
Like install/program path.

In fact, a program I made only used the Uninstall registry entry and nothing else.
This makes it easy to remove the program.
(the program in question didn't really need the registry itself but having it listed in the Uninstall is a nice feature)

And should the user ever delete your app folder,
Windows still allow you to unistall and clean up the registry,
however if your program stored stuff all over the registry
they would be left behind, bloating the registry.