杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1850|回复: 0

NSIS打包+管理员权限+多用户安装

[复制链接]
发表于 2016-9-2 16:59:43 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

您需要 登录 才可以下载或查看,没有账号?立即注册

x

  1. ; Author: Lilla (lilla@earthlink.net) 2003-06-13
  2. ; function IsUserAdmin uses plugin \NSIS\PlusgIns\UserInfo.dll
  3. ; This function is based upon code in \NSIS\Contrib\UserInfo\UserInfo.nsi
  4. ; This function was tested under NSIS 2 beta 4 (latest CVS as of this writing).
  5. ;
  6. ; Usage:
  7. ;   Call IsUserAdmin
  8. ;   Pop $R0   ; at this point $R0 is "true" or "false"
  9. ;
  10. Function IsUserAdmin
  11. Push $R0
  12. Push $R1
  13. Push $R2

  14. ClearErrors
  15. UserInfo::GetName
  16. IfErrors Win9x
  17. Pop $R1
  18. UserInfo::GetAccountType
  19. Pop $R2

  20. StrCmp $R2 "Admin" 0 Continue
  21. ; Observation: I get here when running Win98SE. (Lilla)
  22. ; The functions UserInfo.dll looks for are there on Win98 too,
  23. ; but just don't work. So UserInfo.dll, knowing that admin isn't required
  24. ; on Win98, returns admin anyway. (per kichik)
  25. ; MessageBox MB_OK 'User "$R1" is in the Administrators group'
  26. StrCpy $R0 "true"
  27. Goto Done

  28. Continue:
  29. ; You should still check for an empty string because the functions
  30. ; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
  31. StrCmp $R2 "" Win9x
  32. StrCpy $R0 "false"
  33. ;MessageBox MB_OK 'User "$R1" is in the "$R2" group'
  34. Goto Done

  35. Win9x:
  36. ; comment/message below is by UserInfo.nsi author:
  37. ; This one means you don't need to care about admin or
  38. ; not admin because Windows 9x doesn't either
  39. ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
  40. StrCpy $R0 "true"

  41. Done:
  42. ;MessageBox MB_OK 'User= "$R1"  AccountType= "$R2"  IsUserAdmin= "$R0"'

  43. Pop $R2
  44. Pop $R1
  45. Exch $R0
  46. FunctionEnd

复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-19 13:09 , Processed in 0.105639 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表