##############################################################
### Check user account type.
### If it is not "Admin", ask user to continue or abort...
##############################################################
Function CheckAccessRights
  Call CheckLanguage
  StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
   DetailPrint "Now checking user access rights..."
  StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +2
   DetailPrint "Проверка прав доступа..."
  ClearErrors
  Var /GLOBAL UserName
  UserInfo::GetName
  IfErrors AccessWin9x
  Pop $UserName
  Var /GLOBAL AccountType
  UserInfo::GetAccountType
  IfErrors AccessWin9x
  Pop $AccountType
  StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
   DetailPrint 'Found user "$UserName" of type "$AccountType".'
  StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +2
   DetailPrint 'Найден пользователь "$UserName" типа "$AccountType".'
  StrCmp $AccountType "Admin" AccessGranted AccessConfirmation
  AccessConfirmation:
   StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
    MessageBox MB_YESNO 'User "$UserName" of type "$AccountType" \
                         have no Administrator rights. \
                         Application may work incorrectly after such installation. \
                         Continue installation?' \
                         IDYES AccessGranted IDNO AccessDenied
   StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +2
    MessageBox MB_YESNO 'Пользователь "$UserName" типа "$AccountType" \
                         не имеет прав Администратора. \
                         Приложение может работать некорректно после такой инсталляции. \
                         Все равно продолжить инсталляцию?' \
                         IDYES AccessGranted IDNO AccessDenied
  AccessDenied:
   StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +4
    DetailPrint 'Access denied to user "$UserName" of type "$AccountType".'
    MessageBox MB_OK 'Access denied to user "$UserName" of type "$AccountType".'
    Abort 'Access denied to user "$UserName" of type "$AccountType".'
   StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +4
    DetailPrint 'Доступ закрыт для пользователя "$UserName" типа "$AccountType".'
    MessageBox MB_OK 'Доступ закрыт для пользователя "$UserName" типа "$AccountType".'
    Abort 'Доступ закрыт для пользователя "$UserName" типа "$AccountType".'
  AccessWin9x:
   StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
    DetailPrint "Don't care about rights in Windows 9x."
   StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +2
    DetailPrint "Права доступа не играют роли в Windows 9x."
  AccessGranted:
   StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +3
    DetailPrint 'Access granted to user "$UserName" of type "$AccountType".'
    DetailPrint 'Now can continue installation...'
   StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +3
    DetailPrint 'Доступ открыт для пользователя  "$UserName" типа "$AccountType".'
    DetailPrint 'Можно продолжать инсталляцию...'
FunctionEnd
##############################################################
Function un.CheckAccessRights
  Call un.CheckLanguage
  StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
   DetailPrint "Now checking user access rights..."
  StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +2
   DetailPrint "Проверка прав доступа..."
  ClearErrors
  #Var /GLOBAL UserName
  UserInfo::GetName
  IfErrors AccessWin9x
  Pop $UserName
  #Var /GLOBAL AccountType
  UserInfo::GetAccountType
  IfErrors AccessWin9x
  Pop $AccountType
  StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
   DetailPrint 'Found user "$UserName" of type "$AccountType".'
  StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +2
   DetailPrint 'Найден пользователь "$UserName" типа "$AccountType".'
  StrCmp $AccountType "Admin" AccessGranted AccessConfirmation
  AccessConfirmation:
   StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
    MessageBox MB_YESNO 'User "$UserName" of type "$AccountType" \
                         have no Administrator rights. \
                         Uninstallation may fails. \
                         Continue uninstallation?' \
                         IDYES AccessGranted IDNO AccessDenied
   StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +2
    MessageBox MB_YESNO 'Пользователь "$UserName" типа "$AccountType" \
                         не имеет прав Администратора. \
                         Деинсталляция может пройти некорректно. \
                         Все равно продолжить деинсталляцию?' \
                         IDYES AccessGranted IDNO AccessDenied
  AccessDenied:
   StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +4
    DetailPrint 'Access denied to user "$UserName" of type "$AccountType".'
    MessageBox MB_OK 'Access denied to user "$UserName" of type "$AccountType".'
    Abort 'Access denied to user "$UserName" of type "$AccountType".'
   StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +4
    DetailPrint 'Доступ закрыт для пользователя "$UserName" типа "$AccountType".'
    MessageBox MB_OK 'Доступ закрыт для пользователя "$UserName" типа "$AccountType".'
    Abort 'Доступ закрыт для пользователя "$UserName" типа "$AccountType".'
  AccessWin9x:
   StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +2
    DetailPrint "Don't care about rights in Windows 9x."
   StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +2
    DetailPrint "Права доступа не играют роли в Windows 9x."
  AccessGranted:
   StrCmp $LANGUAGE ${LANG_ENGLISH} 0 +3
    DetailPrint 'Access granted to user "$UserName" of type "$AccountType".'
    DetailPrint 'Now can continue uninstallation...'
   StrCmp $LANGUAGE ${LANG_RUSSIAN} 0 +3
    DetailPrint 'Доступ открыт для пользователя  "$UserName" типа "$AccountType".'
    DetailPrint 'Можно продолжать деинсталляцию...'
FunctionEnd
##############################################################
