PDA

View Full Version : Create UnInstall ShortCut / Icon revisited.



NewsArchive
12-19-2001, 01:00 AM
There was an eariler posting back in November regarding how to create an
UnInstall Icon on your desktop or create an UnInstall shortcut off the
program menu. The problem with the solution that was offered was it always
prompted for reboot when the uninstall is done; if launched from the
Add/Remove programs it just showed the standard Finish screen. Different
behavior.

I re-did the solution and moved it to the OnMoved event. This should
uninstall programs as if the user ran it from Add/Remove Programs. Note: In
this example, I am creating a shortcut off the Start/Program Menu/ Product
name. PROGRAM_FOLDER_NAME is a resource string that I have set to the
product name we want on the start menu (You can use FOLDER_NAME if you
want).

function OnMoved()
STRING szKeyBase;
STRING szUnInstall;
STRING szDrive;
NUMBER nTemp_1, nTemp_2;
begin
if !MAINTENANCE then
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szKeyBase =
"\\Software\\Microsoft\\Windows\\CurrentVersion\\UnInstall\\" +
PRODUCT_GUID;

if (RegDBGetKeyValueEx(szKeyBase, "UninstallString",
nTemp_1, szUnInstall, nTemp_2) = 0 ) then
// Shouldn't have to quote it - LongPathToQuote(szUnInstall, TRUE);
ParsePath (szDrive, DISK1TARGET, DISK);
AddFolderIcon( FOLDER_PROGRAMS^@PROGRAM_FOLDER_NAME,
"Uninstall " + @PRODUCT_DISPLAY_NAME, szUnInstall,
szDrive, "", 0, "", REPLACE);
else
MessageBox ("Unable to retrieve the UnInstall Key:\n" +
szKeyBase, SEVERE);
abort;
endif;
endif;
end;