杉宫竹苑工作室

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

通过读取kernel32.dll获取系统版本

[复制链接]
发表于 2017-2-23 21:05:28 | 显示全部楼层 |阅读模式

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

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

x
  1. ################################################################################
  2. ### 注意:早期版本 (包括 2.46 官方版) 的 System 插件不支持 p 类型,需改为 i。
  3. ### 例如:pR1、p.R2、p${VS_VERSION_INFO} 等,改为 iR1、i.R2、i${VS_VERSION_INFO}
  4. ### 如果修改后结果仍为 0,请尝试使用最新 2.46.x、3.0 等版本的 System.dll 插件。
  5. ################################################################################
  6. !ifndef RT_VERSION
  7. !define RT_VERSION      16
  8. !endif
  9. !ifndef VS_FILE_INFO
  10. !define VS_FILE_INFO    ${RT_VERSION}
  11. !endif
  12. !ifndef VS_VERSION_INFO
  13. !define VS_VERSION_INFO 1
  14. !endif

  15. # 获取真正的系统版本号
  16. Function GetRealOSVersion
  17.     Push $R0
  18.     Push $R1
  19.     Push $R2
  20.     Push $R3
  21.     Push $R4
  22.     Push $R5
  23.     Push $R6
  24.     StrCpy $R0 0
  25.     System::Call 'kernel32::LoadLibrary(t"kernel32.dll")p.R1'
  26.     IntCmp $R1 0 _ver_err_done
  27.     System::Call 'kernel32::FindResource(pR1,p${VS_VERSION_INFO},p${VS_FILE_INFO})p.R2'
  28.     IntCmp $R2 0 _ver_err_free
  29.     System::Call 'kernel32::LoadResource(pR1,pR2)p.R3'
  30.     IntCmp $R3 0 _ver_err_free
  31.     System::Call 'kernel32::LockResource(pR3)p.R4'
  32.     IntCmp $R4 0 _ver_err_free
  33.     System::Call "*$R4(&i2,&i2.R5,&i2,&w16,&i2,i,i,i.R6)"
  34.     IntCmp $R5 0 _ver_err_free
  35.     IntFmt $R0 "0x%08X" $R6
  36. _ver_err_free:
  37.     System::Call "kernel32::FreeLibrary(pR1)"
  38. _ver_err_done:
  39.     Pop $R6
  40.     Pop $R5
  41.     Pop $R4
  42.     Pop $R3
  43.     Pop $R2
  44.     Pop $R1
  45.     Exch $R0
  46. FunctionEnd
  47. ################################################################################
  48. ################################################################################
  49. !AddPluginDir .

  50. Name WinVer
  51. OutFile WinVer.exe
  52. InstallDir $TEMP

  53. XPStyle on
  54. InstallColors /windows
  55. ShowInstDetails show
  56. RequestExecutionLevel admin

  57. Page instfiles

  58. Section -Main
  59.     # 0x00050000  5.0  Windows 2000
  60.     # 0x00050001  5.1  Windows XP
  61.     # 0x00050002  5.2  Windows XP (x64), Windows Server 2003, Windows Server 2003 R2
  62.     # 0x00060000  6.0  Windows Vista,    Windows Server 2008
  63.     # 0x00060001  6.1  Windows 7,        Windows Server 2008 R2
  64.     # 0x00060002  6.2  Windows 8,        Windows Server 2012
  65.     # 0x00060003  6.3  Windows 8.1,      Windows Server 2012 R2
  66.     # 0x000A0000  10.0 Windows 10,       Windows Server Technical Preview

  67.     Call GetRealOSVersion
  68.     Pop $R0
  69.     # 如果结果为 0 请参考本文件顶部说明
  70.     DetailPrint "$R0"

  71.     IntOp $0 $R0 >> 16
  72.     IntOp $1 $R0 & 0xFFFF
  73.     DetailPrint "$0.$1"
  74. SectionEnd
复制代码


完整脚本附件下载
RealOSVer.zip
回复

使用道具 举报

 楼主| 发表于 2017-2-23 21:05:55 | 显示全部楼层
  1. ################################################################################
  2. ### 注意:早期版本 (包括 2.46 官方版) 的 System 插件不支持 p 类型,需改为 i。
  3. ### 例如:pR1、p.R2、p${VS_VERSION_INFO} 等,改为 iR1、i.R2、i${VS_VERSION_INFO}
  4. ### 如果修改后结果仍为 0,请尝试使用最新 2.46.x、3.0 等版本的 System.dll 插件。
  5. ################################################################################
  6. Function GetRealOSVersion
  7.     Push $R0
  8.     Push $R1
  9.     Push $R2
  10.     Push $R3
  11.     Push $R4
  12.     StrCpy $R0 0
  13.     System::Call "netapi32::NetWkstaGetInfo(pn,i100,*p.R1)i.R2"
  14.     StrCmp $R2 0 0 +5
  15.     System::Call "*$R1(i,p,p,i.R3,i.R4)"
  16.     # $R3 是主版本号,如 Windows 7 就是 6
  17.     # $R4 是次版本号,如 Windows 7 就是 1
  18.     # 这里将其组合为 DWORD 即 32 位整数
  19.     IntOp $R0 $R3 << 16
  20.     IntOp $R0 $R0 | $R4
  21.     System::Call "netapi32::NetApiBufferFree(pR1)"
  22.     # 将结果格式化为十六进制表示法
  23.     IntFmt $R0 "0x%08X" $R0
  24.     Pop $R4
  25.     Pop $R3
  26.     Pop $R2
  27.     Pop $R1
  28.     Exch $R0
  29. FunctionEnd
  30. ################################################################################
  31. ################################################################################
  32. !AddPluginDir .

  33. Name WinVer
  34. OutFile WinVer.exe
  35. InstallDir $TEMP

  36. XPStyle on
  37. InstallColors /windows
  38. ShowInstDetails show
  39. RequestExecutionLevel admin

  40. Page instfiles

  41. Section -Main
  42.     # 0x00050000  5.0  Windows 2000
  43.     # 0x00050001  5.1  Windows XP
  44.     # 0x00050002  5.2  Windows XP (x64), Windows Server 2003, Windows Server 2003 R2
  45.     # 0x00060000  6.0  Windows Vista,    Windows Server 2008
  46.     # 0x00060001  6.1  Windows 7,        Windows Server 2008 R2
  47.     # 0x00060002  6.2  Windows 8,        Windows Server 2012
  48.     # 0x00060003  6.3  Windows 8.1,      Windows Server 2012 R2
  49.     # 0x000A0000  10.0 Windows 10,       Windows Server Technical Preview

  50.     Call GetRealOSVersion
  51.     Pop $R0
  52.     # 如果结果为 0 请参考本文件顶部说明
  53.     DetailPrint "$R0"

  54.     # 分离主次版本号
  55.     IntOp $0 $R0 >> 16
  56.     IntOp $1 $R0 & 0xFFFF
  57.     DetailPrint "$0.$1"
  58. SectionEnd
复制代码



完整脚本附件下载
RealOSVer2.zip
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-19 17:04 , Processed in 0.112652 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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