setup.iss 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #define MyAppShortName "Telegram"
  2. #define MyAppName "Telegram Desktop"
  3. #define MyAppPublisher "Telegram FZ-LLC"
  4. #define MyAppURL "https://desktop.telegram.org"
  5. #define MyAppExeName "Telegram.exe"
  6. #define MyAppId "53F49750-6209-4FBF-9CA8-7A333C87D1ED"
  7. #define CurrentYear GetDateTimeString('yyyy','','')
  8. [Setup]
  9. ; NOTE: The value of AppId uniquely identifies this application.
  10. ; Do not use the same AppId value in installers for other applications.
  11. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
  12. AppId={{{#MyAppId}}
  13. AppName={#MyAppName}
  14. AppVersion={#MyAppVersion}
  15. AppCopyright={#MyAppPublisher} 2014-{#CurrentYear}
  16. AppPublisher={#MyAppPublisher}
  17. AppPublisherURL={#MyAppURL}
  18. AppSupportURL={#MyAppURL}
  19. AppUpdatesURL={#MyAppURL}
  20. DefaultDirName={userappdata}\{#MyAppName}
  21. DefaultGroupName={#MyAppName}
  22. AllowNoIcons=yes
  23. OutputDir={#ReleasePath}
  24. SetupIconFile={#SourcePath}..\Resources\art\icon256.ico
  25. UninstallDisplayName={#MyAppName}
  26. UninstallDisplayIcon={app}\Telegram.exe
  27. Compression=lzma
  28. SolidCompression=yes
  29. DisableStartupPrompt=yes
  30. PrivilegesRequired=lowest
  31. VersionInfoVersion={#MyAppVersion}.0
  32. CloseApplications=force
  33. DisableDirPage=no
  34. DisableProgramGroupPage=no
  35. WizardStyle=modern
  36. SignTool=sha256
  37. #if MyBuildTarget == "winarm"
  38. ArchitecturesAllowed="arm64"
  39. OutputBaseFilename=tsetup-arm64.{#MyAppVersionFull}
  40. #define ArchModulesFolder "arm64"
  41. AppVerName={#MyAppName} {#MyAppVersion} arm64
  42. #elif MyBuildTarget == "win64"
  43. ArchitecturesAllowed="x64compatible"
  44. ArchitecturesInstallIn64BitMode="x64compatible"
  45. OutputBaseFilename=tsetup-x64.{#MyAppVersionFull}
  46. #define ArchModulesFolder "x64"
  47. AppVerName={#MyAppName} {#MyAppVersion} 64bit
  48. #else
  49. OutputBaseFilename=tsetup.{#MyAppVersionFull}
  50. #define ArchModulesFolder "x86"
  51. AppVerName={#MyAppName} {#MyAppVersion} 32bit
  52. #endif
  53. #define ModulesFolder "modules\" + ArchModulesFolder
  54. [Languages]
  55. Name: "english"; MessagesFile: "compiler:Default.isl"
  56. Name: "it"; MessagesFile: "compiler:Languages\Italian.isl"
  57. Name: "es"; MessagesFile: "compiler:Languages\Spanish.isl"
  58. Name: "de"; MessagesFile: "compiler:Languages\German.isl"
  59. Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl"
  60. Name: "pt_BR"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
  61. Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl"
  62. Name: "fr"; MessagesFile: "compiler:Languages\French.isl"
  63. Name: "ua"; MessagesFile: "compiler:Languages\Ukrainian.isl"
  64. [Tasks]
  65. Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"
  66. Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1
  67. [Files]
  68. Source: "{#ReleasePath}\Telegram.exe"; DestDir: "{app}"; Flags: ignoreversion
  69. Source: "{#ReleasePath}\Updater.exe"; DestDir: "{app}"; Flags: ignoreversion
  70. #if MyBuildTarget != "winarm"
  71. Source: "{#ReleasePath}\{#ModulesFolder}\d3d\d3dcompiler_47.dll"; DestDir: "{app}\{#ModulesFolder}\d3d"; Flags: ignoreversion
  72. #endif
  73. ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
  74. [Icons]
  75. Name: "{group}\{#MyAppShortName}"; Filename: "{app}\{#MyAppExeName}"
  76. Name: "{group}\{cm:UninstallProgram,{#MyAppShortName}}"; Filename: "{uninstallexe}"
  77. Name: "{userdesktop}\{#MyAppShortName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
  78. Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppShortName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
  79. [Run]
  80. Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppShortName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
  81. [UninstallDelete]
  82. Type: files; Name: "{app}\data"
  83. Type: files; Name: "{app}\data_config"
  84. Type: files; Name: "{app}\log.txt"
  85. Type: filesandordirs; Name: "{app}\DebugLogs"
  86. Type: filesandordirs; Name: "{app}\tupdates"
  87. Type: filesandordirs; Name: "{app}\tdata"
  88. Type: filesandordirs; Name: "{app}\tcache"
  89. Type: filesandordirs; Name: "{app}\tdumps"
  90. Type: filesandordirs; Name: "{app}\modules"
  91. Type: dirifempty; Name: "{app}"
  92. Type: files; Name: "{userappdata}\{#MyAppName}\data"
  93. Type: files; Name: "{userappdata}\{#MyAppName}\data_config"
  94. Type: files; Name: "{userappdata}\{#MyAppName}\log.txt"
  95. Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\DebugLogs"
  96. Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tupdates"
  97. Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tdata"
  98. Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tcache"
  99. Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\tdumps"
  100. Type: filesandordirs; Name: "{userappdata}\{#MyAppName}\modules"
  101. Type: dirifempty; Name: "{userappdata}\{#MyAppName}"
  102. [Code]
  103. procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
  104. var ResultCode: Integer;
  105. begin
  106. if CurUninstallStep = usUninstall then
  107. begin
  108. ShellExec('', ExpandConstant('{app}\{#MyAppExeName}'), '-cleanup', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
  109. end;
  110. end;
  111. const CSIDL_DESKTOPDIRECTORY = $0010;
  112. CSIDL_COMMON_DESKTOPDIRECTORY = $0019;
  113. procedure CurStepChanged(CurStep: TSetupStep);
  114. var ResultCode: Integer;
  115. HasOldKey: Boolean;
  116. HasNewKey: Boolean;
  117. HasOldLnk: Boolean;
  118. HasNewLnk: Boolean;
  119. UserDesktopLnk: String;
  120. CommonDesktopLnk: String;
  121. begin
  122. if CurStep = ssPostInstall then
  123. begin
  124. HasNewKey := RegKeyExists(HKEY_CURRENT_USER, 'Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1') or RegKeyExists(HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1');
  125. HasOldKey := RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1') or RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{{#MyAppId}}_is1');
  126. UserDesktopLnk := ExpandFileName(GetShellFolderByCSIDL(CSIDL_DESKTOPDIRECTORY, False) + '\{#MyAppShortName}.lnk');
  127. CommonDesktopLnk := ExpandFileName(GetShellFolderByCSIDL(CSIDL_COMMON_DESKTOPDIRECTORY, False) + '\{#MyAppShortName}.lnk');
  128. HasNewLnk := FileExists(UserDesktopLnk);
  129. HasOldLnk := FileExists(CommonDesktopLnk) and (UserDesktopLnk <> CommonDesktopLnk);
  130. if (HasOldKey and HasNewKey) or (HasOldLnk and HasNewLnk) then
  131. begin
  132. if (GetWindowsVersion >= $06000000) then // Vista or later
  133. ShellExec('runas', ExpandConstant('{app}\{#MyAppExeName}'), '-fixprevious', '', SW_SHOW, ewWaitUntilTerminated, ResultCode)
  134. else
  135. ShellExec('', ExpandConstant('{app}\{#MyAppExeName}'), '-fixprevious', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
  136. end;
  137. end;
  138. end;