示例示例
这是一个如何使用注册表中的值来检查 dotNET 4.5 或更高版本的示例。我建议把这段代码放在像 .OnInit
这样的地方,因为这会在其他任何事情发生之前执行; 这样,它会在复制任何文件或发生注册表更改之前检查 .NET。
;=#
;= Define the registry key we're looking for.
!define DOTNET `SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full`
Section "Main"
ClearErrors ;= Clear any errors we may have encountered before hand.
ReadRegDWORD $0 HKLM `${DOTNET}` `Release` ;= Read the value of Release.
IfErrors +3 ;= If there is an error than there is no .NET installed so we jump 3 lines down which lands on MessageBox.
IntCmp $0 394806 +5 0 +5 ;= Compares the value for v4.6.2 if it matches then we jump 5 lines and avoids the MessageBox
IntCmp $0 394802 +4 0 +4 ;= Remember to check for Windows 10's value aswell as the above line won't.
MessageBox MB_ICONSTOP|MB_TOPMOST `You must have v4.6.2 or greater of the .NET Framework installed. Launcher aborting!` ;= If the check failed then we alert the user the required version wasn't found.
Call Unload ;= We call the Unload function here because we failed the .NET check.
Quit ;= Closes the Launcher
SectionEnd