Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function IsMyClickOnceAppInstalled: Boolean;
- begin
- Result := RegKeyExists(HKEY_CURRENT_USER,'Software\Microsoft\Windows\CurrentVersion\Uninstall\myapp');
- end;
- procedure UninstallMyClickOnceApp;
- var
- ErrorCode: Integer;
- begin
- // knowing if the rundll32.exe failed to run is quite pointless here, so I've omitted
- // a return value here (ErrorCode will be always 0)
- ShellExec('runas', 'rundll32.exe', 'dfshim.dll,ShArpMaintain...', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
- end;
- function InitializeSetup: Boolean;
- begin
- Result := True;
- // check if the app. is installed before uninstalling
- if IsMyClickOnceAppInstalled then
- begin
- // the app is installed, run the uninstaller
- UninstallMyClickOnceApp;
- // check once again if the app. is installed; if the user cancelled the uninstaller or
- // something went wrong (which you won't be able to determine), exit the setup
- if IsMyClickOnceAppInstalled then
- begin
- Result := False;
- MsgBox('Ok, you don''t want to uninstall the previous version or you were not lucky ' +
- 'enough and the uninstallation failed. Setup will now exit.', mbInformation, MB_OK);
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement