반응형
# 설치 경로에 '$'가 포함된 특수 경로이면 해당 경로를 찾아서 SetOutPath 설정, '$'가 포함되어 있지 않으면 들어온 경로 그대로 설정.
# 호출 예
# ${GetSpecialPathReplaced} '반환' '특수 경로가 포함된 경로'
# ${GetSpecialPathReplaced} $0 "$DESKTOP\test"
# $0 == '$DESKTOP 부분이 로컬 PC의 환경에 맞춰 경로를 얻어오고 나머지 뒷 부분은 그대로.'
!define CSIDL_DESKTOP '0x0' # Desktop path ($DESKTOP)
!define CSIDL_PROGRAMS '0x2' # Programs path
!define CSIDL_PERSONAL '0x5' # My document path
!define CSIDL_FAVORITES '0x6' # Favorites path ($FAVORITES)
!define CSIDL_STARTUP '0x7' # Startup path
!define CSIDL_RECENT '0x8' # Recent documents path ($RECENT)
!define CSIDL_SENDTO '0x9' # Sendto documents path ($SENDTO)
!define CSIDL_STARTMENU '0xB' # StartMenu path
!define CSIDL_MUSIC '0xD' # My Music path ($MUSIC)
!define CSIDL_DESKTOPDIR '0x10' # Desktop Directory path
!define CSIDL_COMPUTER '0x11' # My Computer path
!define CSIDL_FONTS '0x14' # Fonts directory path ($FONTS)
!define CSIDL_TEMPLATES '0x15' # Windows Template path ($TEMP)
!define CSIDL_APPDATA '0x1A' # Application Data path ($APPDATA)
!define CSIDL_LOCALAPPDATA '0x1C' # Local Application Data path ($LOCALAPPDATA)
!define CSIDL_INTERNETCACHE '0x20' # Internet Cache path ($INTERNET_CACHE)
!define CSIDL_COOKIES '0x21' # Cookies path ($COOKIES)
!define CSIDL_HISTORY '0x22' # History path ($HISTORY)
!define CSIDL_COMMONAPPDATA '0x23' # Common Application Data path
!define CSIDL_SYSTEM '0x25' # System path ($SYSDIR)
!define CSIDL_PROGRAMFILES '0x26' # Program Files path ($PROGRAMFILES, $PROGRAMFILES32, $PROGRAMFILES64)
!define CSIDL_MYPICTURES '0x27' # My Pictures path ($PICTURES)
!define CSIDL_COMMONPROGRAMFILES '0x2B' # Common Program Files path ($COMMONFILES, $COMMONFILES32, $COMMONFILES64)
!macro _GetSpecialPathReplaced un
Function ${un}_GetSpecialPathReplaced
Exch $R0 # 특수 경로를 의미하는 토큰이 포함 된 설치 경로
Push $R1
Push $0
Push $2
# 바탕화면
${StrContains} $R1 "$$DESKTOP" $R0
${If} $R1 != ""
System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT, t .r2, i ${CSIDL_DESKTOP}, i0)i.r0'
${StrReplace} $R1 "$$DESKTOP" $2 $R0
Goto GetSpecialPathReplacedEnd
${EndIf}
# Program Files
${StrContains} $R1 "$$PROGRAMFILES" $R0
${If} $R1 != ""
System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT, t .r2, i ${CSIDL_PROGRAMFILES}, i0)i.r0'
${StrReplace} $R1 "$$PROGRAMFILES" $2 $R0
Goto GetSpecialPathReplacedEnd
${EndIf}
# Public
${StrContains} $R1 "$$PUBLIC" $R0
${If} $R1 != ""
ReadEnvStr $2 "PUBLIC"
${StrReplace} $R1 "$$PUBLIC" $2 $R0
Goto GetSpecialPathReplacedEnd
${EndIf}
# LOCALLOW
${StrContains} $R1 "$$LOCALLOW" $R0
${If} $R1 != ""
System::Call 'shell32::SHGetSpecialFolderPath(i $HWNDPARENT, t .r2, i ${CSIDL_APPDATA}, i0)i.r0'
${StrReplace} $2 "Roaming" "LocalLow" $2
${StrReplace} $R1 "$$LOCALLOW" $2 $R0
Goto GetSpecialPathReplacedEnd
${EndIf}
StrCpy $R1 $R0
GetSpecialPathReplacedEnd:
Pop $2
Push $R1
Exch
Pop $0
Exch
Pop $R1
Exch
Pop $R0
FunctionEnd
!macroend
!insertmacro _GetSpecialPathReplaced ""
!insertmacro _GetSpecialPathReplaced "un."
!macro GetSpecialPathReplaced OUTPUT path
Push "${path}"
!ifndef __UNINSTALL__
Call _GetSpecialPathReplaced
!else
Call un._GetSpecialPathReplaced
!endif
Pop "${OUTPUT}"
!macroend
!define GetSpecialPathReplaced "!insertmacro GetSpecialPathReplaced"
반응형
'NSIS > Reference' 카테고리의 다른 글
[NSIS] 인증서 설치 (0) | 2024.12.25 |
---|---|
[NSIS] 권한 상승 (0) | 2024.12.25 |
[NSIS] 재배포 패키지 설치 여부 체크 후 설치하는 방법 (0) | 2024.12.11 |
[NSIS] 32비트와 64비트 모듈 등록하는 법. (regsvr32) (0) | 2024.12.11 |
[NSIS] 커맨드 라인 옵션 값 받아오기 + 사일런트 모드 설치 (0) | 2024.12.11 |