View Single Post
Old 22nd July 2019, 17:24   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,153
If you want your main application shortcut to be based on a language string things get tricky.

* Option A, delete all possible names:

PHP Code:
!define LNKNAME_ENGLISH "MyApp"
!define LNKNAME_SWEDISH "BorkApp"
LangString LnkName ${LANG_ENGLISH"${LNKNAME_ENGLISH}"
LangString LnkName ${LANG_SWEDISH"${LNKNAME_SWEDISH}"

Section
CreateShortcut 
"$SMPrograms\$(LnkName).lnk" "$InstDir\MyApp.exe"
SectionEnd

Section Uninstall
Delete 
"$SMPrograms\${LNKNAME_ENGLISH}.lnk"
Delete "$SMPrograms\${LNKNAME_SWEDISH}.lnk"
SectionEnd 
* Option B, storage:

Store the shortcut name somewhere (.ini or registry) when installing and use that name when uninstalling.

* Option C, shell display names (Vista+):

PHP Code:
LangString LnkDisplayName ...
Section
WriteIniStr 
"$SMPrograms\Desktop.ini" "LocalizedFileNames" "MyApp.lnk" "$(LnkDisplayName)"
SetFileAttributes "$SMPrograms\Desktop.ini" SYSTEM|HIDDEN|ARCHIVE
CreateShortcut 
"$SMPrograms\MyApp.lnk" "$InstDir\MyApp.exe"
SectionEnd

Section Uninstall
Delete 
"$SMPrograms\MyApp.lnk"
DeleteINIStr "$SMPrograms\Desktop.ini" "LocalizedFileNames" "MyApp.lnk"
SectionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote