helper.iss 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. [Code]
  2. {
  3. Helper functions
  4. }
  5. {
  6. Checks to see if the installer is an 'upgrade'
  7. }
  8. function IsUpgrade: Boolean;
  9. var
  10. Value: string;
  11. UninstallKey: string;
  12. begin
  13. UninstallKey := 'Software\Microsoft\Windows\CurrentVersion\Uninstall\' +
  14. ExpandConstant('{#SetupSetting("AppId")}') + '_is1';
  15. Result := (RegQueryStringValue(HKLM, UninstallKey, 'UninstallString', Value) or
  16. RegQueryStringValue(HKCU, UninstallKey, 'UninstallString', Value)) and (Value <> '');
  17. end;
  18. {
  19. Kills a running program by its filename
  20. }
  21. procedure TaskKill(fileName: String);
  22. var
  23. ResultCode: Integer;
  24. begin
  25. Exec(ExpandConstant('taskkill.exe'), '/f /im ' + '"' + fileName + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  26. end;
  27. {
  28. Executes the MSI Uninstall by GUID functionality
  29. }
  30. function MsiExecUnins(appId: String): Integer;
  31. var
  32. ResultCode: Integer;
  33. begin
  34. ShellExec('', 'msiexec.exe', '/x ' + appId + ' /norestart /qb', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  35. Result := ResultCode;
  36. end;