Rev 90 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 90 | Rev 94 | ||
---|---|---|---|
Line 93... | Line 93... | ||
93 | 93 | ||
94 | const |
94 | const |
95 | FOLDERID_SavedGames: TGuid = '{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}'; // do not localize |
95 | FOLDERID_SavedGames: TGuid = '{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}'; // do not localize |
96 | 96 | ||
97 | // Useful functions |
97 | // Useful functions |
- | 98 | procedure SpaceMission_SwitchLanguage; |
|
98 | function GetKnownFolderPath(const rfid: TGUID): string; |
99 | function GetKnownFolderPath(const rfid: TGUID): string; |
99 | function KillTask(ExeFileName: string): Integer; |
100 | function KillTask(ExeFileName: string): Integer; |
100 | procedure CheckForUpdates(ViaThinkSoftProjectName: string; AVersion: string); |
101 | procedure CheckForUpdates(ViaThinkSoftProjectName: string; AVersion: string); |
101 | 102 | ||
102 | implementation |
103 | implementation |
103 | 104 | ||
104 | uses |
105 | uses |
105 | Windows, SysUtils, Dialogs, ActiveX, ShlObj, TlHelp32, wininet, Forms, ShellAPI, |
106 | Windows, SysUtils, Dialogs, ActiveX, ShlObj, TlHelp32, wininet, Forms, ShellAPI, |
106 | System.UITypes; |
107 | System.UITypes; |
107 | 108 | ||
- | 109 | procedure SwitchLanguage(newLang: string); |
|
- | 110 | var |
|
- | 111 | bakHInst: hInst; |
|
- | 112 | modFileName: string; |
|
- | 113 | begin |
|
- | 114 | SetLocaleOverride(newLang); |
|
- | 115 | ||
- | 116 | // Note: SetLocaleOverride() does not work, because LibModuleList.ResInstance |
|
- | 117 | // is already set and won't be re-set by the FindResourceHInstance()! |
|
- | 118 | bakHInst := LibModuleList.ResInstance; |
|
- | 119 | modFileName := ChangeFileExt(ParamStr(0),'.'+GetLocaleOverride(ParamStr(0))); |
|
- | 120 | LibModuleList.ResInstance := LoadResourceModule(PChar(modFileName)); |
|
- | 121 | if LibModuleList.ResInstance = 0 then |
|
- | 122 | LibModuleList.ResInstance := LibModuleList.Instance; |
|
- | 123 | FreeLibrary(bakHInst); |
|
- | 124 | end; |
|
- | 125 | ||
- | 126 | function GetUserDefaultUILanguage: LANGID; stdcall; external 'kernel32'; |
|
- | 127 | ||
- | 128 | procedure SpaceMission_SwitchLanguage; |
|
- | 129 | begin |
|
- | 130 | // We need this because of a tricky problem... |
|
- | 131 | // Our base language is German (DE), and we have a translation for English USA (ENU) |
|
- | 132 | // If the system locale is not exactly ENU (even ENG is not accepted), then the base language (German) will be used. |
|
- | 133 | // But much more people are speaking English than German. So we need to force the system to use ENU instead of DE. |
|
- | 134 | // This decision if we choose DE or ENU is done by the language selected during setup. |
|
- | 135 | if (GetUserDefaultUILanguage and $FF) <> LANG_GERMAN then |
|
- | 136 | SwitchLanguage('ENU'); |
|
- | 137 | end; |
|
- | 138 | ||
108 | function GetKnownFolderPath(const rfid: TGUID): string; |
139 | function GetKnownFolderPath(const rfid: TGUID): string; |
109 | var |
140 | var |
110 | OutPath: PWideChar; |
141 | OutPath: PWideChar; |
111 | begin |
142 | begin |
112 | // https://www.delphipraxis.net/135471-unit-zur-verwendung-von-shgetknownfolderpath.html |
143 | // https://www.delphipraxis.net/135471-unit-zur-verwendung-von-shgetknownfolderpath.html |