1 ; Inno Setup Script for Wammu installation
2 ; Copyright (c) 2006 Michal Èihaø
3 ; Language selection code based on GTK+ 2 installation script
4 ; made by Jernej Simoncic, <jernej.simoncic@guest.arnes.si>
6 #define MyAppDosName
"wammu"
7 #define MyAppName
"Wammu"
8 #define MyAppVersion
"0.30"
9 #define MyAppPublisher
"Micha Èihaø"
10 #define MyAppURL
"http://wammu.eu/"
11 #define MyAppPublisherURL
"http://cihar.com/"
12 #define MyAppBugsURL
"http://bugs.wammu.eu/"
13 #define MyAppDescription
"Wammu Mobile Phone Manager"
14 #define MyAppExeName
"wammu.exe"
15 #define MyAppUrlName
"wammu.url"
16 #define MyAppBugsUrlName
"wammu-bugs.url"
20 AppVerName
={#MyAppName} {#MyAppVersion}
21 AppPublisher
={#MyAppPublisher}
22 AppPublisherURL
={#MyAppPublisherURL}
23 AppSupportURL
={#MyAppBugsURL}
24 AppUpdatesURL
={#MyAppURL}
25 DefaultDirName
={pf}\
{#MyAppName}
26 DefaultGroupName
={#MyAppName}
29 OutputBaseFilename
={#MyAppDosName}-{#MyAppVersion}-setup
30 Compression
=lzma
/ultra
32 InternalCompressLevel
=ultra
33 VersionInfoVersion
={#MyAppVersion}
34 VersionInfoCompany
={#MyAppPublisher}
35 VersionInfoDescription
={#MyAppDescription}
36 ShowLanguageDialog
=yes
37 AppVersion
={#MyAppVersion}
38 UninstallDisplayIcon
={app}\share\pixmaps\wammu
.ico
39 AppModifyPath
="{uninstallexe}" /langsetup
40 ChangesEnvironment
=true
41 ;SetupIconFile={app}\icon\wammu.ico
44 Name
: en
; MessagesFile
: compiler
:Default
.isl
45 ;Name: af; MessagesFile: compiler:Languages\Afrikaans.isl
46 Name
: ca
; MessagesFile
: compiler
:Languages\Catalan
.isl
47 Name
: cs
; MessagesFile
: compiler
:Languages\Czech
.isl
48 Name
: de
; MessagesFile
: compiler
:Languages\German
.isl
49 ;Name: el; MessagesFile: compiler:Languages\Greek.isl
50 Name
: es
; MessagesFile
: compiler
:Languages\Spanish
.isl
51 ;Name: et; MessagesFile: compiler:Languages\Estonian.isl
52 Name
: fi
; MessagesFile
: compiler
:Languages\Finnish
.isl
53 Name
: fr
; MessagesFile
: compiler
:Languages\French
.isl
54 ;Name: gl; MessagesFile: compiler:Languages\Galician.isl
55 Name
: he
; MessagesFile
: compiler
:Languages\Hebrew
.isl
56 Name
: hu
; MessagesFile
: compiler
:Languages\Hungarian
.isl
57 ;Name: id; MessagesFile: compiler:Languages\Indonesian.isl
58 Name
: it
; MessagesFile
: compiler
:Languages\Italian
.isl
59 ;Name: ko; MessagesFile: compiler:Languages\Korean.isl
60 Name
: nl
; MessagesFile
: compiler
:Languages\Dutch
.isl
61 Name
: pl
; MessagesFile
: compiler
:Languages\Polish
.isl
62 Name
: pt_BR
; MessagesFile
: compiler
:Languages\BrazilianPortuguese
.isl
63 Name
: ru
; MessagesFile
: compiler
:Languages\Russian
.isl
64 Name
: sk
; MessagesFile
: compiler
:Languages\Slovak
.isl
65 ;Name: sv; MessagesFile: compiler:Languages\Swedish.isl
66 ;Name: zh_tw; MessagesFile: compiler:Languages\SimpChinese.isl
67 ;Name: zh_cz; MessagesFile: compiler:Languages\TradChinese.isl
70 Name
: desktopicon; Description
: {cm:CreateDesktopIcon}; GroupDescription
: {cm:AdditionalIcons}; Flags
: unchecked
73 Source
: dist\
*; DestDir
: {app}; Flags
: ignoreversion recursesubdirs createallsubdirs
; Excludes
: locale
74 Source
: uninst
.isl
; DestDir
: {app}
75 Source
: dist\share\locale\
*; DestDir
: {app}\share\locale
; Flags
: ignoreversion recursesubdirs createallsubdirs
; Components
: " Translations"; Tasks
: ; Languages
:
78 Filename
: {app}\
{#MyAppUrlName}; Section
: InternetShortcut
; Key
: URL
; String: {#MyAppURL}
79 Filename
: {app}\
{#MyAppBugsUrlName}; Section
: InternetShortcut
; Key
: URL
; String: {#MyAppBugsURL}
82 Name
: {group}\
{#MyAppName}; Filename
: {app}\
{#MyAppExeName}; IconFilename
: {app}\share\pixmaps\wammu
.ico
; IconIndex
: 0
83 Name
: {group}\
{cm:ProgramOnTheWeb,{#MyAppName}}
; Filename
: {app}\
{#MyAppUrlName}
84 Name
: {group}\
{cm:ReportBug,{#MyAppName}}
; Filename
: {app}\
{#MyAppBugsUrlName}
85 Name
: {group}\
{cm:UninstallProgram,{#MyAppName}}
; Filename
: {uninstallexe}
86 Name
: {userdesktop}\
{#MyAppName}; Filename
: {app}\
{#MyAppExeName}; Tasks
: desktopicon
87 Name
: {group}\
{cm:SelectLanguage}; Filename
: {uninstallexe}; Parameters
: /langsetup
; IconFilename
: {app}\share\pixmaps\wammu
.ico
; IconIndex
: 0
90 Filename
: {app}\
{#MyAppExeName}; Description
: {cm:LaunchProgram,{#MyAppName}}
; Flags
: nowait postinstall skipifsilent unchecked
91 Filename
: {uninstallexe}; Parameters
: /langsetup
; Description
: {cm:SelectLanguage}; Flags
: postinstall nowait
94 Type: files; Name
: {app}\
{#MyAppUrlName}
95 Type: files; Name
: {app}\
{#MyAppBugsUrlName}
98 en
.ReportBug
=Report bug
in application
%1
99 cs
.ReportBug
=Nahlásit chybu v aplikaci
%1
100 en
.SelectLanguage
=Select application language
101 cs
.SelectLanguage
=Zvolit jazyk aplikace
104 Root
: HKCU
; Subkey
: Environment
; ValueType
: string; ValueName
: LANG
; ValueData
: {language}; Check
: UsingWinNT
106 ; Following part is heavily based on GTK+ 2 setup
110 function SendMessageTimeout(hWnd
: HWND
; Msg
: Cardinal; wParam
: DWORD
; lParam
: String; fuFlags
, uTimeout
: Cardinal; lpdwResult
: DWORD
): {Int64}Cardinal; external 'SendMessageTimeoutA@user32 stdcall';
113 frmLangChooser
: TForm
;
114 cbUser
, cbSystem
: TComboBox
;
117 WM_SETTINGCHANGE
= 26;
118 //HWND_BROADCAST
= $FFFF;
119 SMTO_ABORTIFHUNG
= 2;
121 function RevPos(const SearchStr
, Str
: string): Integer;
125 if (Length(SearchStr
) < Length(Str
)) and (Pos(SearchStr
, Str
) > 0) then
126 for i
:= (Length(Str
) - Length(SearchStr
) + 1) downto 1 do
129 if Copy(Str
, i
, Length(SearchStr
)) = SearchStr
then
141 function ExtractLang(const Txt
: String): String;
146 if (S
[Length(S
)] = ')') then
150 S
:= Copy(Txt
,i
+1,Length(Txt
)-i
-1)
160 function GetLangIndex(Items
: TStrings
; Lang
: String): Integer;
164 Lang
:= LowerCase(Lang
);
165 for i
:= 0 to Items
.Count
- 1 do
167 S
:= LowerCase(ExtractLang(Items
.Strings
[i
]));
172 if (i
>= Items
.Count
) then
179 function GetTransStr(const Str
: String): String; //ExpandConstant('{cm:...}') doesn
't work on uninstall
181 Result := GetIniString('CustomMessages
',Str,'',ExpandConstant('{app}\uninst
.isl
'));
183 if (Result = '') then
184 RaiseException(Str + ' not found
in translation
file.');
188 procedure LanguageForm;
189 var lblInfo, lblUser, lblSystem: TLabel;
190 btnOK,btnCancel: TButton;
193 lang1,lang2,regSys,regUser: String;
194 AutoExec: TArrayOfString;
198 frmLangChooser := CreateCustomForm();
200 with frmLangChooser do
202 ClientWidth := ScaleX(321);
203 ClientHeight := ScaleY(119);
204 Caption := GetTransStr('LangTitle
');
205 Position := poScreenCenter;
209 lblInfo := TLabel.Create(frmLangChooser);
212 Parent := frmLangChooser;
215 Width := ScaleX(283);
216 Height := ScaleY(13);
217 Caption := GetTransStr('LangText
');
221 lblUser := TLabel.Create(frmLangChooser);
224 Parent := frmLangChooser;
227 Width := ScaleX(119);
228 Height := ScaleY(13);
229 Caption := GetTransStr('LangUser
');
230 FocusControl := cbUser;
234 lblSystem := TLabel.Create(frmLangChooser);
237 Parent := frmLangChooser;
241 Height := ScaleY(13);
242 Caption := GetTransStr('LangSystem
');
243 FocusControl := cbSystem;
247 cbUser := TComboBox.Create(frmLangChooser);
250 Parent := frmLangChooser;
251 Style := csDropDownList;
254 Width := ScaleX(169);
255 Height := ScaleY(16);
256 Hint := GetTransStr('LangUserHint
');
263 cbSystem := TComboBox.Create(frmLangChooser);
266 Parent := frmLangChooser;
267 Style := csDropDownList;
270 Width := ScaleX(169);
271 Height := ScaleY(16);
272 Hint := GetTransStr('LangSystemHint
');
279 btnOK := TButton.Create(frmLangChooser);
282 Parent := frmLangChooser;
286 Height := ScaleY(23);
287 Caption := SetupMessage(msgButtonOK);
294 btnCancel := TButton.Create(frmLangChooser);
297 Parent := frmLangChooser;
301 Height := ScaleY(23);
302 Caption := SetupMessage(msgButtonCancel);
308 cbUser.Items.Add(GetTransStr('LangDefault
'));
309 cbUser.Items.Add('English (C
)');
310 //cbSystem.Items.Add(GetTransStr('LangDefault
'));
312 if FindFirst(ExpandConstant('{app}\share\locale\
*'),frMsgs) then
317 if ((frMsgs.Attributes and FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY) and ((frMsgs.Name <> '.') and (frMsgs.Name <> '..')) then
321 lang1 := frMsgs.Name;
322 StringChange(lang1,'@','_
'); //custom messages only support letters,numbers and _
323 lang1 := GetTransStr('Lang_
'+lang1+'');
328 i := pos('@',frMsgs.Name);
329 if (lang1 = '') and (i > 0) then
331 lang1 := GetTransStr('Lang_
'+Copy(frMsgs.Name,1,i-1)+'');
332 lang2 := Copy(frMsgs.Name,i+1,length(frMsgs.Name))
337 if (lang1 = '') and (Length(frMsgs.Name) > 2) then
339 lang1 := GetTransStr('Lang_
'+Copy(frMsgs.Name,1,2)+'');
344 case lowercase(lang2) of
345 'latn
': lang2 := 'Latin
';
348 if (lang1 <> '') then
350 if (lang2 <> '') then
352 cbUser.Items.Add(lang1+' '+lang2+' ('+frMsgs.Name+')');
355 cbUser.Items.Add(lang1+' ('+frMsgs.Name+')');
359 cbUser.Items.Add(frMsgs.Name);
363 until not FindNext(frMsgs);
365 cbSystem.Items := cbUser.Items;
374 if not IsAdminLoggedOn then //only admins can change system-wide environment variables
376 cbSystem.Enabled := False;
377 lblSystem.Enabled := False;
380 if RegQueryStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment
','LANG
',regSys) then
381 cbSystem.ItemIndex := GetLangIndex(cbSystem.Items,regSys)
383 cbSystem.ItemIndex := 0;
385 if cbSystem.ItemIndex = -1 then
386 cbSystem.ItemIndex := cbSystem.Items.Add(regSys);
389 if RegQueryStringValue(HKEY_CURRENT_USER,'Environment
','LANG
',regUser) then
390 cbUser.ItemIndex := GetLangIndex(cbSystem.Items,regUser)
392 cbUser.ItemIndex := 0;
394 if cbUser.ItemIndex = -1 then
395 cbUser.ItemIndex := cbUser.Items.Add(regUser);
399 if frmLangChooser.ShowModal = 1 then
401 regSys := ExtractLang(cbSystem.Items.Strings[cbSystem.ItemIndex]);
405 regUser := ExtractLang(cbUser.Items.Strings[cbUser.ItemIndex]);
407 if cbUser.ItemIndex <> 0 then
409 if not RegWriteStringValue(HKEY_CURRENT_USER,'Environment
','LANG
',regUser) then
410 MsgBox(GetTransStr('LangRegUserFailed
'),mbCriticalError,mb_ok);
412 if RegValueExists(HKEY_CURRENT_USER,'Environment
','LANG
') and
413 (not RegDeleteValue(HKEY_CURRENT_USER,'Environment
','LANG
')) then
414 MsgBox(GetTransStr('LangRegUserFailed
'),mbCriticalError,mb_ok);
416 if IsAdminLoggedOn then
418 if cbSystem.ItemIndex <> 0 then
420 if not RegWriteStringValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment
','LANG
',regSys) then
421 MsgBox(GetTransStr('LangRegSysFailed
'),mbCriticalError,mb_ok);
423 if RegValueExists(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment
','LANG
') and
424 (not RegDeleteValue(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Control\Session Manager\Environment
','LANG
')) then
425 MsgBox(GetTransStr('LangRegSysFailed
'),mbCriticalError,mb_ok);
428 //straight from the Inno source
429 SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 'Environment
', SMTO_ABORTIFHUNG, 5000, MsgResult);
433 if not FileCopy(ExpandConstant('{sd}\AutoExec
.bat
'),ExpandConstant('{sd}\AutoExec
.WAM
'),False) then
434 if MsgBox(GetTransStr('LangAutoExecBackupFailed
'),mbConfirmation,mb_yesno) = idno then
437 if LoadStringsFromFile(ExpandConstant('{sd}\Autoexec
.bat
'), AutoExec) then
439 for i := GetArrayLength(AutoExec) - 1 downto 0 do
440 if pos('set lang
=',LowerCase(AutoExec[i])) > 0 then
441 if (i>0) and (i<(GetArrayLength(AutoExec)-1))
442 and (LowerCase(AutoExec[i-1]) = 'REM
/=== by Wammu Language Setup
===\')
443 and (LowerCase(AutoExec
[i
+1]) = 'REM \=== by Wammu Language Setup ===/') then
445 for j
:= i
to GetArrayLength(AutoExec
) - 2 do //remove previous setting
446 AutoExec
[j
-1] := AutoExec
[j
+1];
447 SetArrayLength(AutoExec
,GetArrayLength(AutoExec
) - 3);
450 i
:= GetArrayLength(AutoExec
);
451 SetArrayLength(AutoExec
,i
+ 3);
452 AutoExec
[i
] := 'REM /=== by Wammu Language Setup ===\';
453 AutoExec[i+1] := 'SET LANG
='+regSys;
454 AutoExec[i+2] := 'REM \
=== by Wammu Language Setup
===/';
456 if SaveStringsToFile(ExpandConstant('{sd}\AutoExec
.bat
'),AutoExec,False) then
457 MsgBox(GetTransStr('LangRestartRequired
'),mbInformation,mb_ok)
459 MsgBox(GetTransStr('LangErrorSavingAutoExec
'),mbCriticalError,mb_ok);
462 MsgBox(GetTransStr('LangErrorLoadingAutoExec
'), mbCriticalError, MB_OK);
469 function InitializeUninstall(): Boolean;
475 for i := 1 to ParamCount do
477 if LowerCase(ParamStr(i)) = '/langsetup
' then
491 Name: Translations; Description: Translation data; Types: custom full; Languages: