本文介绍了NSIS检测Windows版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在NSIS中,有一种方法可以确定用户当前正在运行的Windows版本?

In NSIS is there a way to determine what version of windows the user is currently running?

我要这样做的原因是因为我的安装程序在Windows XP计算机上看起来有所不同.我的安装程序使用MUI2,但我似乎没有与Windows 7中相同的GUI按钮(我认为其称为XP样式),并且主安装程序窗口比Windows 7中的大得多(Windows 7的大小约为500 x 400像素).在使用MUI2的安装程序中存在这些差异是否正常? 我以为MUI2使Windows XP和更高版本的外观保持一致?

The reason I want to do this is because my installer looks different on a Windows XP computer. My installer uses MUI2 but I dont seem to have the same GUI buttons(I think its called XP Style) as I do in Windows 7 and the main installer window is much larger than in Windows 7(where its about 500 by 400 pixels). Is it normal to a have these differences in an installer using MUI2? I thought MUI2 made the look consistant in windows versions XP and up?

要克服安装程序窗口大小的差异,我的解决方案是检测用户是否使用Windows XP并相应地调整窗口大小.这可能吗?

To overcome the difference in installer window size, my solution is to detect if the user is using Windows XP and resize the window accordingly. Is this possible?

我需要使窗口具有特定的大小,因为我有一个背景图像,并且该图像的宽度为500px,因此,如果安装程序窗口较大,则会出现空白.我可以将背景图像更改为更宽,但对我自己来说,最简单的解决方案是我上面解释过的解决方案

I need to have the window a specific size because I have a background image and the image is 500px wide so if the installer window is bigger I have a blank gap. I can change the background image to be wider but the easiest solution for myself is the one I explained above

推荐答案

如果安德斯的答案不够明确(花了我几个小时使它正确),这是一个更加初学者友好"的版本.

In case Anders' answer is not explicit enough (took me a few hours to get it right), here is a more "beginner's friendly" version.

您将需要在cd.nsi文件的顶部添加!include WinVer.nsh .

You will need to add !include WinVer.nsh to the top section of the cd.nsi file.

然后您可以使用如下代码:

You then can use code like this:

${If} ${IsWinXP}
     MessageBox MB_OK|MB_ICONEXCLAMATION "We have Win XP"
${EndIf}

这是我测试过的唯一功能,但是WinVer.nsh文件以包含其功能的迷你手册开头,

This is the only function I tested, but the WinVer.nsh file starts with a mini-manual with its functions, which include:

  • AtLeastWin< version> ,它检查安装程序是否至少在指定的Windows版本上运行.
  • IsWin< version> ,它会检查安装程序是否完全按照指定的Windows版本运行.
  • AtMostWin< version> ,它检查安装程序是否最多在指定的Windows版本上运行.
  • AtLeastWin<version> which checks if the installer is running on Windows version at least as specified.
  • IsWin<version> which checks if the installer is running on Windows version exactly as specified.
  • AtMostWin<version> which checks if the installer is running on Windows version at most as specified.

< version> 可以替换为以下值(可能更多,具体取决于WinVer.nsh文件的最新程度): 95 98 ME NT4 2000 XP 2003 Vista 2008 7 2008R2

<version> can be replaced with the following values (and maybe more, depending on how recent your WinVer.nsh file is): 95, 98, ME, NT4, 2000, XP, 2003, Vista, 2008, 7, 2008R2

WinVer.nsh文件中还有更多功能和一些用法示例,该文件可能位于 C:\ Program Files \ NSIS \ Include 之类的地方,例如:

There are some more functions and some usage examples in the WinVer.nsh file, which is probably located somewhere like C:\Program Files\NSIS\Include, like:

  • AtLeastServicePack ,它检查安装程序是否至少在指定的Windows Service Pack版本上运行.
  • IsServicePack ,它检查安装程序是否在指定的Windows Service Pack版本上运行.
  • AtMostServicePack ,它检查安装程序是否最多在指定的Windows服务版本包上运行.
  • IsWin2003R2 (未提供更多详细信息)
  • IsStarterEdition (未提供更多详细信息)
  • OSHasMediaCenter (未提供更多详细信息)
  • OSHasTabletSupport (未提供更多详细信息)
  • AtLeastServicePack which checks if the installer is running on Windows service pack version at least as specified.
  • IsServicePack which checks if the installer is running on Windows service pack version exactly as specified.
  • AtMostServicePack which checks if the installer is running on Windows service version pack at most as specified.
  • IsWin2003R2 (no more details supplied)
  • IsStarterEdition (no more details supplied)
  • OSHasMediaCenter (no more details supplied)
  • OSHasTabletSupport (no more details supplied)

这篇关于NSIS检测Windows版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 06:38