Add your uninstaller to add/remove programs.

Share your advanced PureBasic knowledge/code with the community.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Add your uninstaller to add/remove programs.

Post 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).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
josku_x
Addict
Addict
Posts: 997
Joined: Sat Sep 24, 2005 2:08 pm

Post by josku_x »

Coool! I never came up that the Add/Remove thing in Control Panel uses Registry?!?!?!?!

That's cool example :D
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post 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.
Post Reply