Go NSIS: Use Sectionsetflags to automatically tick specific sections according to different environments

Source: Internet
Author: User

From: http://www.flighty.cn/html/bushu/20140526_232.html in the Microsoft SQL2000+SP4 integrated installation package, you can automatically check the corresponding version according to the target operating system, A classmate asked me how this function is realized, today frivolous write a short unified reply. The point is to use the SECTIONSETFLAGS directive, which is described in the NSIs User manual: Set section markers. Marked as a 32-bit integer. The first bit (low) represents whether the section is currently selected, and the second represents whether the segment is a section group (please do not modify this here unless you really understand), the third person represents whether the segment is the end of a segment group (again, do not modify), and the fourth bit indicates whether the section text is black or not, The fifth digit indicates whether the section is read-only, the sixth-digit indicates whether the segment group is automatically expanded, the seventh-digit is partially selected, and the eighth bit is a partially selected segment group switch internal use, and the nineth bit is used to reflect the section name change. If an out-of-range segment is specified, an incorrect token is placed. Each tag name begins with ' Sf_ ':!define sf_selected 1!define sf_secgrp 2!define sf_secgrpend 4!define Sf_bold 8!define Sf_ro!define Sf_expand!define sf_pselectedWe only use the first place. Here is the full script:
; less frivolous www.nsisfans.comName"automatic selection of specific sections according to different environments"OutFile"automatically check specific sections of. exe according to different environments"!include"Mui2.nsh"!include"Winver.nsh"!insertmacro mui_page_components!insertmacro mui_page_instfiles!insertmacro mui_language"Simpchinese"InstallDir"$TEMP" Section/O"SQL2000 Development Edition"SEC01 sectionin RO MessageBox MB_OK| Mb_iconexclamation'Development Version! 'sectionendsection/O"SQL2000 Enterprise Edition"SEC02 sectionin RO MessageBox MB_OK| Mb_iconexclamation'Enterprise Edition! 'sectionendfunction. oninit${if} ${isserveros} sectiongetflags ${sec02} $R 0 intop $R 0|${sf_selected} sectionsetflags ${sec02} $0${else} sectiongetflags ${sec01} $R 0 intop $R 0|${sf_selected} sectionsetflags ${sec01} $0${endif}functionend
Another: In the OnInit is certainly not limited to judging the operating system, but can be based on the specified characteristics, such as the value of the registry key or the existence of a file. Frivolous here just to mention a train of thought, concrete depends on how we play.

Frivolous zhi (less frivolous) original articles, reproduced please indicate the author and source, thank you! Http://www.flighty.cn/html/bushu/20140526_232.html

Go NSIS: Use Sectionsetflags to automatically tick specific sections according to different environments

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.