; We're going to use the "Modern UI" supplied with NSIS.
!include "MUI.nsh"

; Grabbed from
; http://nsis.sourceforge.net/archive....php?pageid=275
!include "is_user_admin.nsh"

;--------------------------------

Name "Toggle"
OutFile "toggle.exe"

!define PRODUCT_NAME "My Product"

;--------------------------------

  ; Define which components to install.
  !insertmacro MUI_PAGE_COMPONENTS

;--------------------------------

; Sections

Section "!${PRODUCT_NAME}" SecCore
  SectionIn RO
SectionEnd

Section /o "Install for all users?" SecAllUsers
SectionEnd

Section "Desktop icon" SecDesktop
  ; CreateShortcut ...
SectionEnd

Section "Quick Launch icon" SecQuick
  ; CreateShortcut ...
SectionEnd

; --------------------------------
; Descriptions

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SecAllUsers} "Install for all users or just the current user. (Requires Administrator privileges.)"
  !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "A ${PRODUCT_NAME} icon on the desktop."
  !insertmacro MUI_DESCRIPTION_TEXT ${SecQuick} "A ${PRODUCT_NAME} icon in the Quick Launch bar."
  !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "The ${PRODUCT_NAME} files."
!insertmacro MUI_FUNCTION_DESCRIPTION_END

;--------------------------------

; Functions

Function .onInit

  ; If the user does *not* have administrator privileges,
  ; then make section SecAllUsers readonly.
  Call IsUserAdmin
  Pop $0
  StrCmp $0 "true" cont 0
    ; Set the fifth bit to set the read only flag.
    !define READ_ONLY 0x00000010
    SectionGetFlags ${SecAllUsers} $0
    IntOp $0 $0 | ${READ_ONLY}
    SectionSetFlags ${SecAllUsers} $0
    !undef READ_ONLY
cont:

FunctionEnd

