This is mostly directed at Prapper since I am modifying his launcher for Glary Utilities.
I am creating a launcher for CUE Splitter which only creates a registry file. I am trying to implement language switching in the launcher, but since the language is stored in the registry file, I'm not really sure how to update it. I have included the code below, but it obviously doesn't work. Any help would be appreciated.
Thanks.
;Copyright 2004-2010 John T. Haller ;Copyright 2008-2010 Devo ;Website: http://PortableApps.com/CUESplitterPortable ;This software is OSI Certified Open Source Software. ;OSI Certified is a certification mark of the Open Source Initiative. ;This program is free software; you can redistribute it and/or ;modify it under the terms of the GNU General Public License ;as published by the Free Software Foundation; either version 2 ;of the License, or (at your option) any later version. ;This program is distributed in the hope that it will be useful, ;but WITHOUT ANY WARRANTY; without even the implied warranty of ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;GNU General Public License for more details. ;You should have received a copy of the GNU General Public License ;along with this program; if not, write to the Free Software ;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. !define PORTABLEAPPNAME "CUE Splitter Portable" !define APPNAME "CUE Splitter" !define NAME "CUESplitterPortable" !define VER "1.6.8.0" !define WEBSITE "PortableApps.com/CUESplitterPortable" !define DEFAULTEXE "CUE_Splitter.exe" !define DEFAULTAPPDIR "CUESplitter" !define DEFAULTSETTINGSDIR "settings" !define LAUNCHERLANGUAGE "English" ;=== Program Details Name "${PORTABLEAPPNAME}" OutFile "..\..\${NAME}.exe" Caption "${PORTABLEAPPNAME} | PortableApps.com" VIProductVersion "${VER}" VIAddVersionKey ProductName "${PORTABLEAPPNAME}" VIAddVersionKey Comments "Allows ${APPNAME} to be run from a removable drive. For additional details, visit ${WEBSITE}" VIAddVersionKey CompanyName "PortableApps.com" VIAddVersionKey LegalCopyright "PortableApps.com & Contributors" VIAddVersionKey FileDescription "${PORTABLEAPPNAME}" VIAddVersionKey FileVersion "${VER}" VIAddVersionKey ProductVersion "${VER}" VIAddVersionKey InternalName "${PORTABLEAPPNAME}" VIAddVersionKey LegalTrademarks "PortableApps.com is a Trademark of Rare Ideas, LLC." VIAddVersionKey OriginalFilename "${NAME}.exe" ;VIAddVersionKey PrivateBuild "" ;VIAddVersionKey SpecialBuild "" ;=== Runtime Switches CRCCheck On WindowIcon Off SilentInstall Silent AutoCloseWindow True RequestExecutionLevel user XPStyle On ; Best Compression SetCompress Auto SetCompressor /SOLID lzma SetCompressorDictSize 32 SetDatablockOptimize On ;=== Include ;(Standard NSIS) !include FileFunc.nsh !insertmacro GetParameters !include LogicLib.nsh !include Registry.nsh ;(Custom) !include ReadINIStrWithDefault.nsh ;=== Program Icon Icon "..\..\App\AppInfo\appicon.ico" ;=== Languages LoadLanguageFile "${NSISDIR}\Contrib\Language files\${LAUNCHERLANGUAGE}.nlf" !include PortableApps.comLauncherLANG_${LAUNCHERLANGUAGE}.nsh Var PROGRAMDIRECTORY Var SETTINGSDIRECTORY Var ADDITIONALPARAMETERS Var EXECSTRING Var PROGRAMEXECUTABLE Var INIPATH Var DISABLESPLASHSCREEN Var SECONDARYLAUNCH Var LASTPLUGINSDIRECTORY Var LASTSTARTUP Var MISSINGFILEORPATH Var APPLANGUAGE Section "Main" ;=== Check if already running System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${NAME}") i .r1 ?e' Pop $0 StrCmp $0 0 CheckINI StrCpy $SECONDARYLAUNCH "true" CheckINI: ;=== Find the INI file, if there is one IfFileExists "$EXEDIR\${NAME}.ini" "" NoINI StrCpy $INIPATH "$EXEDIR" ;=== Read the parameters from the INI file ${ReadINIStrWithDefault} $0 "$INIPATH\${NAME}.ini" "${NAME}" "${APPNAME}Directory" "App\${DEFAULTAPPDIR}" StrCpy $PROGRAMDIRECTORY "$EXEDIR\$0" ${ReadINIStrWithDefault} $0 "$INIPATH\${NAME}.ini" "${NAME}" "SettingsDirectory" "Data\${DEFAULTSETTINGSDIR}" StrCpy $SETTINGSDIRECTORY "$EXEDIR\$0" ${ReadINIStrWithDefault} $PROGRAMEXECUTABLE "$INIPATH\${NAME}.ini" "${NAME}" "${APPNAME}Executable" "${DEFAULTEXE}" ${ReadINIStrWithDefault} $ADDITIONALPARAMETERS "$INIPATH\${NAME}.ini" "${NAME}" "AdditionalParameters" "" ${ReadINIStrWithDefault} $DISABLESPLASHSCREEN "$INIPATH\${NAME}.ini" "${NAME}" "DisableSplashScreen" "false" IfFileExists "$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" FoundProgramEXE NoProgramEXE NoINI: ;=== No INI file, so we'll use the defaults StrCpy $PROGRAMEXECUTABLE "${DEFAULTEXE}" StrCpy $ADDITIONALPARAMETERS "" StrCpy $DISABLESPLASHSCREEN "false" IfFileExists "$EXEDIR\App\${DEFAULTAPPDIR}\${DEFAULTEXE}" "" NoProgramEXE StrCpy $PROGRAMDIRECTORY "$EXEDIR\App\${DEFAULTAPPDIR}" StrCpy $SETTINGSDIRECTORY "$EXEDIR\Data\${DEFAULTSETTINGSDIR}" Goto FoundProgramEXE NoProgramEXE: ;=== Program executable not where expected StrCpy $MISSINGFILEORPATH $PROGRAMEXECUTABLE MessageBox MB_OK|MB_ICONEXCLAMATION `$(LauncherFileNotFound)` Goto TheEnd FoundProgramEXE: StrCmp $SECONDARYLAUNCH "true" GetPassedParameters FindProcDLL::FindProc "${DEFAULTEXE}" StrCmp $R0 "1" WarnAnotherInstance DisplaySplash WarnAnotherInstance: MessageBox MB_OK|MB_ICONINFORMATION `$(LauncherAlreadyRunning)` Goto TheEnd DisplaySplash: StrCmp $DISABLESPLASHSCREEN "true" CheckSettings ;=== Show the splash screen before processing the files InitPluginsDir File /oname=$PLUGINSDIR\splash.jpg "${NAME}.jpg" newadvsplash::show /NOUNLOAD 1200 0 0 -1 /L "$PLUGINSDIR\splash.jpg" CheckSettings: ;=== Check for data files IfFileExists "$SETTINGSDIRECTORY\*.*" GetPassedParameters ;=== Create the default settings directory CreateDirectory "$SETTINGSDIRECTORY" GetPassedParameters: ;=== Get any passed parameters ${GetParameters} $0 StrCmp "'$0'" "''" "" LaunchProgramParameters ;=== No parameters StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE"` Goto AdditionalParameters LaunchProgramParameters: StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" $0` AdditionalParameters: StrCmp $ADDITIONALPARAMETERS "" StartupCheck ;=== Additional Parameters StrCpy $EXECSTRING `$EXECSTRING $ADDITIONALPARAMETERS` StartupCheck: StrCmp $SECONDARYLAUNCH "true" LaunchAndExit ;GetPlatformLanguage: ReadEnvStr $0 "PortableApps.comLocaleWinName" StrCpy $APPLANGUAGE $0 "" 5 StrCmp $APPLANGUAGE "" MoveSettings ;if not set, move on ;FixPlatformLanguage: ${IfThen} $APPLANGUAGE == PORTUGUESE ${|} StrCpy $APPLANGUAGE "Portugues (Portugal)" ${|} ${IfThen} $APPLANGUAGE == PORTUGUESEBR ${|} StrCpy $APPLANGUAGE "Portugues (Brazilian)" ${|} ${IfThen} $APPLANGUAGE == SIMPCHINESE ${|} StrCpy $APPLANGUAGE "Chinese (Simplified)" ${|} ${IfThen} $APPLANGUAGE == TRADCHINESE ${|} StrCpy $APPLANGUAGE "Chinese(Traditional)" ${|} ${IfThen} $APPLANGUAGE == SPANISH ${|} StrCpy $APPLANGUAGE "Espanol (America Latina)" ${|} ;CheckAppLanguage: ReadINIStr $0 "$SETTINGSDIRECTORY\Medieval.reg" "Lang_Txt" StrCmp "$APPLANGUAGE" $0 RegistryBackup ;if the same, move on ;SetAppLanguage: IfFileExists "$PROGRAMDIRECTORY\LANG\$APPLANGUAGE" "" RegistrySettings nsExec::Exec REG UPDATE $SETTINGSDIRECTORY\Medieval.reg "Lang_Txt" "$APPLANGUAGE" RegistryBackup: ;=== Backup the registry ${registry::KeyExists} "HKEY_CURRENT_USER\Software\Medieval-BackupBy${NAME}" $R0 StrCmp $R0 "0" RestoreTheKey ${registry::KeyExists} "HKEY_CURRENT_USER\Software\Medieval" $R0 StrCmp $R0 "-1" RestoreTheKey ${registry::MoveKey} "HKEY_CURRENT_USER\Software\Medieval" "HKEY_CURRENT_USER\Software\Medieval-BackupBy${NAME}" $R0 Sleep 100 RestoreTheKey: IfFileExists "$SETTINGSDIRECTORY\Medieval.reg" "" LaunchNow IfFileExists "$WINDIR\system32\reg.exe" "" RestoreTheKey9x nsExec::ExecToStack `"$WINDIR\system32\reg.exe" import "$SETTINGSDIRECTORY\Medieval.reg"` Pop $R0 StrCmp $R0 '0' LaunchNow ;successfully restored key RestoreTheKey9x: ${registry::RestoreKey} "$SETTINGSDIRECTORY\Medieval.reg" $R0 StrCmp $R0 '0' LaunchNow ;successfully restored key StrCpy $FAILEDTORESTOREKEY "true" LaunchNow: Sleep 100 ExecWait $EXECSTRING CheckRunning: Sleep 1000 FindProcDLL::FindProc "${DEFAULTEXE}" StrCmp $R0 "1" CheckRunning StrCmp $FAILEDTORESTOREKEY "true" SetOriginalKeyBack ${registry::SaveKey} "HKEY_CURRENT_USER\Software\Medieval" "$SETTINGSDIRECTORY\Medieval.reg" "" $0 Sleep 100 SetOriginalKeyBack: ${registry::DeleteKey} "HKEY_CURRENT_USER\Software\Medieval" $R0 Sleep 100 ${registry::KeyExists} "HKEY_CURRENT_USER\Software\Medieval-BackupBy${NAME}" $R0 StrCmp $R0 "-1" TheEnd ${registry::MoveKey} "HKEY_CURRENT_USER\Software\Medieval-BackupBy${NAME}" "HKEY_CURRENT_USER\Software\Medieval" $R0 Sleep 100 Goto TheEnd LaunchAndExit: Exec $EXECSTRING TheEnd: ${registry::Unload} newadvsplash::stop /WAIT SectionEnd
can you post the section of the registry?
You might check 7-zip portable. I was looking through that the other day, and the way 7-zip stores the information is in the registry. So maybe that's the goodness you need.
Too many lonely hearts in the real world
Too many bridges you can burn
Too many tables you can't turn
Don't wanna live my life in the real world
7Zip is a good example for this.
"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate
.reg files can be read and written to using ReadINI and WriteINI in NSIS.
Sometimes, the impossible can become possible, if you're awesome!
I've posted the reg file below and I need to update the "Lang_Txt" string. It's about 3/4 of the way down.
Like I said, WriteINI.
WriteINI "X:\path\filename.reg" "HKEY_CURRENT_USER\Software\Medieval\CUE Splitter\Main" "Lang_Txt" $VALUE
Sometimes, the impossible can become possible, if you're awesome!
Thank you very much. I wasn't sure if that would work, but I think I had it in the wrong format when I tried. Thanks again for your help.