NSIS Wiki:Sandbox: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
 
(50 intermediate revisions by 23 users not shown)
Line 5: Line 5:
Keep the page content below this note.
Keep the page content below this note.


[[Category:Browse Wiki Maintenance Services by Name]]
<hr />
 
<!-- keep the note above intact and put the page content right below -->
<!-- keep the note above intact and put the page content right below -->


== Overview ==
This is only a test.
DotNET is a macro written to aid in the deployment of .NET Framework 2.0-based applications using NSIS.


=== What it does ===
test captcha
# Checks the version of the .NET framework on the end-user's computer.
# Prompts them with a yes/no dialog if their version is different than the defined DOTNET_VERSION in the installer's main script.
# If they press yes, the installer downloads the latest .NET Framework 2.0 installer and runs it.


=== Limitations ===
* Only works for .NET Framework 2.0, not 1.0 or 1.1.


== Usage ==
The quick brown fox jumps over the lazy dog.
=== Including the Script ===
Save the Script contents as DotNET.nsh in the same folder as your main script, and put line in your main script like this:
<highlight-nsis>!include "DotNET.nsh"</highlight-nsis>


DotNet.nsh uses the ${if} function of LogicLib, so you also have to include it in your script:
<span id="anchor_name"></span>
<highlight-nsis>!include LogicLib.nsh</highlight-nsis>
== Some long complicated title that no one would want to refer to directly ==


=== Required Variables ===
LIBRARY SYSTEM OF THE FISHER VALLEY
Define the variable DOTNET_VERSION as the full or partial version of .NET Framework your app requires, like so:
kjnb/'/l,m'l'lk
<highlight-nsis>!define DOTNET_VERSION "2.0.50727"</highlight-nsis>
or
<highlight-nsis>!define DOTNET_VERSION "2.0.5"</highlight-nsis>
or
<highlight-nsis>!define DOTNET_VERSION "2"</highlight-nsis>


=== Using the Script ===
<code>  
Insert the macro CheckDotNET into your script inside the first required section of the installer:
!include "MUI2.nsh"   # change this to !include MUI.nsh to see how the code works successfully for MUI1
<highlight-nsis>
Section "Main Section (Required)"
SectionIn RO


!insertmacro CheckDotNET ${DOTNET_VERSION}
; Local bitmap path.
!define BITMAP_FILE res.bmp


#Files here
; --------------------------------------------------------------------------------------------------
SectionEnd
; Installer Settings
</highlight-nsis>
; --------------------------------------------------------------------------------------------------
Name "Background Bitmap"
OutFile "bgbitmap.exe"
ShowInstDetails show
; !define MUI_HEADERIMAGE # this is responsible for the big window
; !define MUI_UI_HEADERIMAGE ".\dimm_beta_img.exe" # modded exe
; --------------------------------------------------------------------------------------------------
; Modern UI Settings
; --------------------------------------------------------------------------------------------------
!define MUI_COMPONENTSPAGE_NODESC
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_CUSTOMFUNCTION_GUIINIT MyGUIInit


== The Script ==
; --------------------------------------------------------------------------------------------------
<div style="overflow: auto; width=100%;">
; Definitions
<highlight-nsis>
; --------------------------------------------------------------------------------------------------
# DotNET version checking macro.
!ifndef LR_LOADFROMFILE
# Written by AnarkiNet(AnarkiNet@gmail.com) originally, modified by eyal0 (for use in http://www.sourceforge.net/projects/itwister)
    !define LR_LOADFROMFILE    0x0010
# Downloads and runs the Microsoft .NET Framework version 2.0 Redistributable and runs it if the user does not have the correct version.
!endif
# To use, call the macro with a string:
!ifndef LR_CREATEDIBSECTION
# !insertmacro CheckDotNET "2"
    !define LR_CREATEDIBSECTION 0x2000
# !insertmacro CheckDotNET "2.0.9"
!endif
# (Version 2.0.9 is less than version 2.0.10.)
!ifndef IMAGE_BITMAP
# All register variables are saved and restored by CheckDotNet
    !define IMAGE_BITMAP        0
# No output
!endif
!ifndef SS_BITMAP
    !define SS_BITMAP          0x0000000E
!endif
!ifndef WS_CHILD
    !define WS_CHILD            0x40000000
!endif
!ifndef WS_VISIBLE
    !define WS_VISIBLE          0x10000000
!endif
!define HWND_TOP            0
!define SWP_NOSIZE          0x0001
!define SWP_NOMOVE          0x0002
!define IDC_BITMAP          1500
!define stRECT "(i, i, i, i) i"
Var hBitmap


!macro CheckDotNET DotNetReqVer
; --------------------------------------------------------------------------------------------------
  !define DOTNET_URL "http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=0856eacb-4362-4b0d-8edd-aab15c5e04f5&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f6%2f7%2f567758a3-759e-473e-bf8f-52154438565a%2fdotnetfx.exe"
; Pages
  DetailPrint "Checking your .NET Framework version..."
; --------------------------------------------------------------------------------------------------
  ;callee register save
!define MUI_PAGE_CUSTOMFUNCTION_SHOW WelcomePageShow
  Push $0
!insertmacro MUI_PAGE_WELCOME
  Push $1
  Push $2
  Push $3
  Push $4
  Push $5
  Push $6 ;backup of intsalled ver
  Push $7 ;backup of DoNetReqVer


  StrCpy $7 ${DotNetReqVer}
!insertmacro MUI_LANGUAGE English


  System::Call "mscoree::GetCORVersion(w .r0, i ${NSIS_MAX_STRLEN}, *i r2r2) i .r1 ?u"
; --------------------------------------------------------------------------------------------------
; Macros
; --------------------------------------------------------------------------------------------------
; Destroy a window.
!macro DestroyWindow HWND IDC
    GetDlgItem $R0 ${HWND} ${IDC}
    System::Call `user32::DestroyWindow(i R0)`
!macroend


  ${If} $0 == 0
; Give window transparent background.
  DetailPrint ".NET Framework not found, download is required for program to run."
!macro SetTransparent HWND IDC
     Goto NoDotNET
    GetDlgItem $R0 ${HWND} ${IDC}
  ${EndIf}
     SetCtlColors $R0 0x444444 transparent
!macroend


  ;at this point, $0 has maybe v2.345.678.
; Refresh window.
  StrCpy $0 $0 $2 1 ;remove the starting "v", $0 has the installed version num as a string
!macro RefreshWindow HWND IDC
  StrCpy $6 $0
    GetDlgItem $R0 ${HWND} ${IDC}
  StrCpy $1 $7 ;$1 has the requested verison num as a string
    ShowWindow $R0 ${SW_HIDE}
    ShowWindow $R0 ${SW_SHOW}
!macroend


  ;MessageBox MB_OKCANCEL "found $0" IDCANCEL GiveUpDotNET
; --------------------------------------------------------------------------------------------------
      
; Functions
  ;MessageBox MB_OKCANCEL "looking for $1" IDCANCEL GiveUpDotNET
; --------------------------------------------------------------------------------------------------
Function MyGUIInit
    ; Extract bitmap image.
    InitPluginsDir
    ReserveFile `${BITMAP_FILE}`
    File `/ONAME=$PLUGINSDIR\res.bmp` `${BITMAP_FILE}`
    ; Get the size of the window.
    System::Call `*${stRECT} .R0`
    System::Call `user32::GetClientRect(i $HWNDPARENT, i R0)`
    System::Call `*$R0${stRECT} (, , .R1, .R2)`
    System::Free $R0
    ; Create bitmap control.
    System::Call `kernel32::GetModuleHandle(i 0) i.R3`
    System::Call `user32::CreateWindowEx(i 0, t "STATIC", t "", i ${SS_BITMAP}|${WS_CHILD}|${WS_VISIBLE}, i 0, i 0, i R1, i R2, i $HWNDPARENT, i ${IDC_BITMAP}, i R3, i 0) i.R1`
    System::Call `user32::SetWindowPos(i R1, i ${HWND_TOP}, i 0, i 0, i 0, i 0, i ${SWP_NOSIZE}|${SWP_NOMOVE})`
    ; Set the bitmap.
    System::Call `user32::LoadImage(i 0, t "$PLUGINSDIR\res.bmp", i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_CREATEDIBSECTION}|${LR_LOADFROMFILE}) i.s`
     Pop $hBitmap
    SendMessage $R1 ${STM_SETIMAGE} ${IMAGE_BITMAP} $hBitmap
    ; Set transparent backgrounds.
    !insertmacro SetTransparent $HWNDPARENT 3
    !insertmacro SetTransparent $HWNDPARENT 1
    !insertmacro SetTransparent $HWNDPARENT 2
    !insertmacro SetTransparent $HWNDPARENT 1034
    !insertmacro SetTransparent $HWNDPARENT 1037
    !insertmacro SetTransparent $HWNDPARENT 1038
    !insertmacro SetTransparent $HWNDPARENT 1028
    !insertmacro SetTransparent $HWNDPARENT 1256
    ; !insertmacro SetTransparent $HWNDPARENT 1045
    !insertmacro SetTransparent $HWNDPARENT 1035
    ; Remove unwanted controls.
    !insertmacro DestroyWindow  $HWNDPARENT 1256
    !insertmacro DestroyWindow  $HWNDPARENT 1028
    ; !insertmacro DestroyWindow  $HWNDPARENT 1039
    !insertmacro DestroyWindow  $HWNDPARENT 1045    # dimm remove line from bottom
    ; !insertmacro DestroyWindow  $HWNDPARENT 1035
    ; !insertmacro DestroyWindow  $HWNDPARENT 1256
FunctionEnd


  ;now let's compare the versions, installed against required <part0>.<part1>.<part2>.
  ${Do}
    StrCpy $2 "" ;clear out the installed part
    StrCpy $3 "" ;clear out the required part


     ${Do}
Function RefreshParentControls
      ${If} $0 == "" ;if there are no more characters in the version
     !insertmacro RefreshWindow $HWNDPARENT 1037
        StrCpy $4 "." ;fake the end of the version string
    !insertmacro RefreshWindow  $HWNDPARENT 1038
      ${Else}
FunctionEnd
        StrCpy $4 $0 1 0 ;$4 = character from the installed ver
        ${If} $4 != "."
          StrCpy $0 $0 ${NSIS_MAX_STRLEN} 1 ;remove that first character from the remaining
        ${EndIf}
      ${EndIf}
     
      ${If} $1 == "" ;if there are no more characters in the version
        StrCpy $5 "." ;fake the end of the version string
      ${Else}
        StrCpy $5 $1 1 0 ;$5 = character from the required ver
        ${If} $5 != "."
          StrCpy $1 $1 ${NSIS_MAX_STRLEN} 1 ;remove that first character from the remaining
        ${EndIf}
      ${EndIf}
      ;MessageBox MB_OKCANCEL "installed $2,$4,$0 required $3,$5,$1" IDCANCEL GiveUpDotNET
      ${If} $4 == "."
      ${AndIf} $5 == "."
        ${ExitDo} ;we're at the end of the part
      ${EndIf}


       ${If} $4 == "." ;if we're at the end of the current installed part
Function WelcomePageShow
        StrCpy $2 "0$2" ;put a zero on the front
       # Sets background image
      ${Else} ;we have another character
    System::Call `user32::LoadImage(i 0, t "$PLUGINSDIR\res.bmp", i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_CREATEDIBSECTION}|${LR_LOADFROMFILE}) i.s`
        StrCpy $2 "$2$4" ;put the next character on the back
    Pop $hBitmap
      ${EndIf}
    ; SendMessage $bitmapWindow ${STM_SETIMAGE} ${IMAGE_BITMAP} $hBitmap
      ${If} $5 == "." ;if we're at the end of the current required part
      # Start solution
        StrCpy $3 "0$3" ;put a zero on the front
    SetCtlColors $mui.WelcomePage ${CTRL_COLOUR} transparent
      ${Else} ;we have another character
    SetCtlColors $mui.WelcomePage.text ${CTRL_COLOUR} transparent
        StrCpy $3 "$3$5" ;put the next character on the back
    SetCtlColors $mui.WelcomePage.title 0x333333 transparent
      ${EndIf}
    !insertmacro DestroyWindow  $HWNDPARENT 1037
     ${Loop}
    !insertmacro DestroyWindow  $HWNDPARENT 1038
     ;MessageBox MB_OKCANCEL "finished parts: installed $2,$4,$0 required $3,$5,$1" IDCANCEL GiveUpDotNET
    !insertmacro DestroyWindow  $HWNDPARENT 1036
     SetCtlColors $0 222425 transparent
     System::Call `user32::DestroyWindow(i $mui.WelcomePage.Image)`


     ${If} $0 != "" ;let's remove the leading period on installed part if it exists
     Call RefreshParentControls
      StrCpy $0 $0 ${NSIS_MAX_STRLEN} 1
FunctionEnd
     ${EndIf}
     ; BrandingText ""
    ${If} $1 != "" ;let's remove the leading period on required part if it exists
      StrCpy $1 $1 ${NSIS_MAX_STRLEN} 1
    ${EndIf}


    ;$2 has the installed part, $3 has the required part
; Free loaded resources.
    ${If} $2 S< $3
Function .onGUIEnd
      IntOp $0 0 - 1 ;$0 = -1, installed less than required
     ; Destroy the bitmap.
      ${ExitDo}
     System::Call `gdi32::DeleteObject(i s)` $hBitmap
    ${ElseIf} $2 S> $3
FunctionEnd
      IntOp $0 0 + 1 ;$0 = 1, installed greater than required
      ${ExitDo}
    ${ElseIf} $2 == ""
     ${AndIf} $3 == ""
      IntOp $0 0 + 0 ;$0 = 0, the versions are identical
      ${ExitDo}
     ${EndIf} ;otherwise we just keep looping through the parts
  ${Loop}


  ${If} $0 < 0
; --------------------------------------------------------------------------------------------------
    DetailPrint ".NET Framework Version found: $6, but is older than the required version: $7"
; Dummy section
    Goto OldDotNET
; --------------------------------------------------------------------------------------------------
  ${Else}
Section "Dummy Section"
    DetailPrint ".NET Framework Version found: $6, equal or newer to required version: $7."
SectionEnd
    Goto NewDotNET
  ${EndIf}
 
NoDotNET:
    MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
    ".NET Framework not installed.$\nRequired Version: $7 or greater.$\nDownload .NET Framework version from www.microsoft.com?" \
    /SD IDYES IDYES DownloadDotNET IDNO NewDotNET
    goto GiveUpDotNET ;IDCANCEL
OldDotNET:
    MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
    "Your .NET Framework version: $6.$\nRequired Version: $7 or greater.$\nDownload .NET Framework version from www.microsoft.com?" \
    /SD IDYES IDYES DownloadDotNET IDNO NewDotNET
    goto GiveUpDotNET ;IDCANCEL
DownloadDotNET:
  DetailPrint "Beginning download of latest .NET Framework version."
  NSISDL::download ${DOTNET_URL} "$TEMP\dotnetfx.exe"
  DetailPrint "Completed download."
  Pop $0
  ${If} $0 == "cancel"
    MessageBox MB_YESNO|MB_ICONEXCLAMATION \
    "Download cancelled.  Continue Installation?" \
    IDYES NewDotNET IDNO GiveUpDotNET
  ${ElseIf} $0 != "success"
    MessageBox MB_YESNO|MB_ICONEXCLAMATION \
    "Download failed:$\n$0$\n$\nContinue Installation?" \
    IDYES NewDotNET IDNO GiveUpDotNET
  ${EndIf}
  DetailPrint "Pausing installation while downloaded .NET Framework installer runs."
  ExecWait '$TEMP\dotnetfx.exe /q /c:"install /q"'
  DetailPrint "Completed .NET Framework install/update. Removing .NET Framework installer."
  Delete "$TEMP\dotnetfx.exe"
  DetailPrint ".NET Framework installer removed."
  goto NewDotNet
 
GiveUpDotNET:
  Abort "Installation cancelled by user."


NewDotNET:
</code>
  DetailPrint "Proceeding with remainder of installation."
  Pop $0
  Pop $1
  Pop $2
  Pop $3
  Pop $4
  Pop $5
  Pop $6 ;backup of intsalled ver
  Pop $7 ;backup of DoNetReqVer
!macroend
</highlight-nsis></div>
 
 
== Overview ==
Added check for MSI3.
 
=== What it does ===
# Checks the version of the MSI on the end-user's computer.
# Prompts them with a yes/no dialog if their version is lower than 3.
# If they press yes, the installer downloads the latest MSI3.1 installer and runs it.
# Checks the version of the .NET framework on the end-user's computer.
# Prompts them with a yes/no dialog if their version is different than the defined DOTNET_VERSION in the installer's main script.
# If they press yes, the installer downloads the latest .NET Framework 2.0 installer and runs it.
 
== The Script With MSI Check ==
<div style="overflow: auto; width=100%;">
<highlight-nsis>
# DotNET and MSI version checking macro.
# Written by AnarkiNet(AnarkiNet@gmail.com) originally, modified by eyal0 (for use in http://www.sourceforge.net/projects/itwister)
# MSI check code based on http://www.codeproject.com/useritems/NSIS.asp
# Downloads the MSI version 3.1 and runs it if the user does not have the correct version.
# Downloads and runs the Microsoft .NET Framework version 2.0 Redistributable and runs it if the user does not have the correct version.
# To use, call the macro with a string:
# !insertmacro CheckDotNET "2"
# !insertmacro CheckDotNET "2.0.9"
# (Version 2.0.9 is less than version 2.0.10.)
# All register variables are saved and restored by CheckDotNet
# No output
!macro CheckDotNET DotNetReqVer
  !define DOTNET_URL "http://www.microsoft.com/downloads/info.aspx?na=90&p=&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=0856eacb-4362-4b0d-8edd-aab15c5e04f5&u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f5%2f6%2f7%2f567758a3-759e-473e-bf8f-52154438565a%2fdotnetfx.exe"
  !define MSI31_URL "http://download.microsoft.com/download/1/4/7/147ded26-931c-4daf-9095-ec7baf996f46/WindowsInstaller-KB893803-v2-x86.exe"
 
  DetailPrint "Checking your .NET Framework version..."
  ;callee register save
  Push $0
  Push $1
  Push $2
  Push $3
  Push $4
  Push $5
  Push $6 ;backup of intsalled ver
  Push $7 ;backup of DoNetReqVer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                              MSI                                          ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  GetDLLVersion "$SYSDIR\msi.dll" $R0 $R1
  IntOp $R2 $R0 / 0x00010000 ; $R2 now contains major version
  IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
  IntOp $R4 $R1 / 0x00010000 ; $R4 now contains release
  IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
  StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"
 
  ${If} $R2 < '3'
    ;options
    SetOutPath "$TEMP"
    SetOverwrite on
   
    MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
    "Your MSI version: $0.$\nRequired Version: 3 or greater.$\nDownload MSI version from www.microsoft.com?" \
    /SD IDYES IDYES DownloadMSI IDNO NewMSI
    goto GiveUpDotNET ;IDCANCEL
   
  ${Else}
 
    DetailPrint "MSI3.1 already installed"
    goto NewMSI
  ${EndIf}
 
DownloadMSI:
  DetailPrint "Beginning download of MSI3.1."
  NSISDL::download ${MSI31_URL} "$TEMP\WindowsInstaller-KB893803-v2-x86.exe"
  DetailPrint "Completed download."
  Pop $0
  ${If} $0 == "cancel"
    MessageBox MB_YESNO|MB_ICONEXCLAMATION \
    "Download cancelled.  Continue Installation?" \
    IDYES NewMSI IDNO GiveUpDotNET
  ${ElseIf} $0 != "success"
    MessageBox MB_YESNO|MB_ICONEXCLAMATION \
    "Download failed:$\n$0$\n$\nContinue Installation?" \
    IDYES NewMSI IDNO GiveUpDotNET
  ${EndIf}
  DetailPrint "Pausing installation while downloaded MSI3.1 installer runs."
  ExecWait '$TEMP\WindowsInstaller-KB893803-v2-x86.exe /quiet /norestart' $0
  DetailPrint "Completed MSI3.1 install/update. Exit code = '$0'. Removing MSI3.1 installer."
  Delete "$TEMP\WindowsInstaller-KB893803-v2-x86.exe"
  DetailPrint "MSI3.1 installer removed."
  goto NewMSI
 
NewMSI:
  DetailPrint "MSI3.1 installation done. Proceeding with remainder of installation."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                  NetFX                                    ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  StrCpy $7 ${DotNetReqVer}
  System::Call "mscoree::GetCORVersion(w .r0, i ${NSIS_MAX_STRLEN}, *i r2r2) i .r1 ?u"
  ${If} $0 == 0
  DetailPrint ".NET Framework not found, download is required for program to run."
    Goto NoDotNET
  ${EndIf}
  ;at this point, $0 has maybe v2.345.678.
  StrCpy $0 $0 $2 1 ;remove the starting "v", $0 has the installed version num as a string
  StrCpy $6 $0
  StrCpy $1 $7 ;$1 has the requested verison num as a string
  ;MessageBox MB_OKCANCEL "found $0" IDCANCEL GiveUpDotNET
   
  ;MessageBox MB_OKCANCEL "looking for $1" IDCANCEL GiveUpDotNET
  ;now let's compare the versions, installed against required <part0>.<part1>.<part2>.
  ${Do}
    StrCpy $2 "" ;clear out the installed part
    StrCpy $3 "" ;clear out the required part
    ${Do}
      ${If} $0 == "" ;if there are no more characters in the version
        StrCpy $4 "." ;fake the end of the version string
      ${Else}
        StrCpy $4 $0 1 0 ;$4 = character from the installed ver
        ${If} $4 != "."
          StrCpy $0 $0 ${NSIS_MAX_STRLEN} 1 ;remove that first character from the remaining
        ${EndIf}
      ${EndIf}
     
      ${If} $1 == ""  ;if there are no more characters in the version
        StrCpy $5 "." ;fake the end of the version string
      ${Else}
        StrCpy $5 $1 1 0 ;$5 = character from the required ver
        ${If} $5 != "."
          StrCpy $1 $1 ${NSIS_MAX_STRLEN} 1 ;remove that first character from the remaining
        ${EndIf}
      ${EndIf}
      ;MessageBox MB_OKCANCEL "installed $2,$4,$0 required $3,$5,$1" IDCANCEL GiveUpDotNET
      ${If} $4 == "."
      ${AndIf} $5 == "."
        ${ExitDo} ;we're at the end of the part
      ${EndIf}
      ${If} $4 == "." ;if we're at the end of the current installed part
        StrCpy $2 "0$2" ;put a zero on the front
      ${Else} ;we have another character
        StrCpy $2 "$2$4" ;put the next character on the back
      ${EndIf}
      ${If} $5 == "." ;if we're at the end of the current required part
        StrCpy $3 "0$3" ;put a zero on the front
      ${Else} ;we have another character
        StrCpy $3 "$3$5" ;put the next character on the back
      ${EndIf}
    ${Loop}
    ;MessageBox MB_OKCANCEL "finished parts: installed $2,$4,$0 required $3,$5,$1" IDCANCEL GiveUpDotNET
    ${If} $0 != "" ;let's remove the leading period on installed part if it exists
      StrCpy $0 $0 ${NSIS_MAX_STRLEN} 1
    ${EndIf}
    ${If} $1 != "" ;let's remove the leading period on required part if it exists
      StrCpy $1 $1 ${NSIS_MAX_STRLEN} 1
    ${EndIf}
    ;$2 has the installed part, $3 has the required part
    ${If} $2 S< $3
      IntOp $0 0 - 1 ;$0 = -1, installed less than required
      ${ExitDo}
    ${ElseIf} $2 S> $3
      IntOp $0 0 + 1 ;$0 = 1, installed greater than required
      ${ExitDo}
    ${ElseIf} $2 == ""
    ${AndIf} $3 == ""
      IntOp $0 0 + 0 ;$0 = 0, the versions are identical
      ${ExitDo}
    ${EndIf} ;otherwise we just keep looping through the parts
  ${Loop}
  ${If} $0 < 0
    DetailPrint ".NET Framework Version found: $6, but is older than the required version: $7"
    Goto OldDotNET
  ${Else}
    DetailPrint ".NET Framework Version found: $6, equal or newer to required version: $7."
    Goto NewDotNET
  ${EndIf}
NoDotNET:
    MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
    ".NET Framework not installed.$\nRequired Version: $7 or greater.$\nDownload .NET Framework version from www.microsoft.com?" \
    /SD IDYES IDYES DownloadDotNET IDNO NewDotNET
    goto GiveUpDotNET ;IDCANCEL
OldDotNET:
    MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
    "Your .NET Framework version: $6.$\nRequired Version: $7 or greater.$\nDownload .NET Framework version from www.microsoft.com?" \
    /SD IDYES IDYES DownloadDotNET IDNO NewDotNET
    goto GiveUpDotNET ;IDCANCEL
DownloadDotNET:
  DetailPrint "Beginning download of latest .NET Framework version."
  NSISDL::download ${DOTNET_URL} "$TEMP\dotnetfx.exe"
  DetailPrint "Completed download."
  Pop $0
  ${If} $0 == "cancel"
    MessageBox MB_YESNO|MB_ICONEXCLAMATION \
    "Download cancelled.  Continue Installation?" \
    IDYES NewDotNET IDNO GiveUpDotNET
  ${ElseIf} $0 != "success"
    MessageBox MB_YESNO|MB_ICONEXCLAMATION \
    "Download failed:$\n$0$\n$\nContinue Installation?" \
    IDYES NewDotNET IDNO GiveUpDotNET
  ${EndIf}
  DetailPrint "Pausing installation while downloaded .NET Framework installer runs."
  ExecWait '$TEMP\dotnetfx.exe /q /c:"install /q"'
  DetailPrint "Completed .NET Framework install/update. Removing .NET Framework installer."
  Delete "$TEMP\dotnetfx.exe"
  DetailPrint ".NET Framework installer removed."
  goto NewDotNet
GiveUpDotNET:
  Abort "Installation cancelled by user."
NewDotNET:
  DetailPrint "Proceeding with remainder of installation."
  Pop $0
  Pop $1
  Pop $2
  Pop $3
  Pop $4
  Pop $5
  Pop $6 ;backup of intsalled ver
  Pop $7 ;backup of DoNetReqVer
!macroend
</highlight-nsis></div>


==CSS==


[[Category:Other Products Handling Functions]]
<code>O01lI</code><hr>
[[Category:Other Products Version Detection Functions]]
<code style="font-family: monospace;">O01lI</code><hr>
[[Category:Internet Functions]]
<code style="font-family: monospace,monospace;">O01lI</code><hr>
<code style="font-family: monospace,serif;">O01lI</code><hr>
<pre>O01lI</pre><hr>
<pre style="font-family: monospace;">O01lI</pre><hr>
<pre style="font-family: monospace,monospace;">O01lI</pre><hr>
<pre style="font-family: monospace,serif;">O01lI</pre><hr>

Latest revision as of 17:15, 15 April 2023

This is where test stuff should be posted, if you don't know how things appear, or want to test if something works which can't be seen by just previewing the page.

Right now, there is nothing being done to this page regularly to delete contents. Maybe a bot or the server will be used for the task, but nothing is sure.

Keep the page content below this note.


This is only a test.

test captcha


The quick brown fox jumps over the lazy dog.

Some long complicated title that no one would want to refer to directly

LIBRARY SYSTEM OF THE FISHER VALLEY kjnb/'/l,m'l'lk

!include "MUI2.nsh" # change this to !include MUI.nsh to see how the code works successfully for MUI1


Local bitmap path.

!define BITMAP_FILE res.bmp

--------------------------------------------------------------------------------------------------
Installer Settings
--------------------------------------------------------------------------------------------------

Name "Background Bitmap" OutFile "bgbitmap.exe" ShowInstDetails show

!define MUI_HEADERIMAGE # this is responsible for the big window
!define MUI_UI_HEADERIMAGE ".\dimm_beta_img.exe" # modded exe
--------------------------------------------------------------------------------------------------
Modern UI Settings
--------------------------------------------------------------------------------------------------

!define MUI_COMPONENTSPAGE_NODESC !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_CUSTOMFUNCTION_GUIINIT MyGUIInit

--------------------------------------------------------------------------------------------------
Definitions
--------------------------------------------------------------------------------------------------

!ifndef LR_LOADFROMFILE

   !define LR_LOADFROMFILE     0x0010

!endif !ifndef LR_CREATEDIBSECTION

   !define LR_CREATEDIBSECTION 0x2000

!endif !ifndef IMAGE_BITMAP

   !define IMAGE_BITMAP        0

!endif !ifndef SS_BITMAP

   !define SS_BITMAP           0x0000000E

!endif !ifndef WS_CHILD

   !define WS_CHILD            0x40000000

!endif !ifndef WS_VISIBLE

   !define WS_VISIBLE          0x10000000

!endif !define HWND_TOP 0 !define SWP_NOSIZE 0x0001 !define SWP_NOMOVE 0x0002 !define IDC_BITMAP 1500 !define stRECT "(i, i, i, i) i" Var hBitmap

--------------------------------------------------------------------------------------------------
Pages
--------------------------------------------------------------------------------------------------

!define MUI_PAGE_CUSTOMFUNCTION_SHOW WelcomePageShow !insertmacro MUI_PAGE_WELCOME

!insertmacro MUI_LANGUAGE English

--------------------------------------------------------------------------------------------------
Macros
--------------------------------------------------------------------------------------------------
Destroy a window.

!macro DestroyWindow HWND IDC

   GetDlgItem $R0 ${HWND} ${IDC}
   System::Call `user32::DestroyWindow(i R0)`

!macroend

Give window transparent background.

!macro SetTransparent HWND IDC

   GetDlgItem $R0 ${HWND} ${IDC}
   SetCtlColors $R0 0x444444 transparent

!macroend

Refresh window.

!macro RefreshWindow HWND IDC

   GetDlgItem $R0 ${HWND} ${IDC}
   ShowWindow $R0 ${SW_HIDE}
   ShowWindow $R0 ${SW_SHOW}

!macroend

--------------------------------------------------------------------------------------------------
Functions
--------------------------------------------------------------------------------------------------

Function MyGUIInit

   ; Extract bitmap image.
   InitPluginsDir
   ReserveFile `${BITMAP_FILE}`
   File `/ONAME=$PLUGINSDIR\res.bmp` `${BITMAP_FILE}`
   ; Get the size of the window.
   System::Call `*${stRECT} .R0`
   System::Call `user32::GetClientRect(i $HWNDPARENT, i R0)`
   System::Call `*$R0${stRECT} (, , .R1, .R2)`
   System::Free $R0
   ; Create bitmap control.
   System::Call `kernel32::GetModuleHandle(i 0) i.R3`
   System::Call `user32::CreateWindowEx(i 0, t "STATIC", t "", i ${SS_BITMAP}|${WS_CHILD}|${WS_VISIBLE}, i 0, i 0, i R1, i R2, i $HWNDPARENT, i ${IDC_BITMAP}, i R3, i 0) i.R1`
   System::Call `user32::SetWindowPos(i R1, i ${HWND_TOP}, i 0, i 0, i 0, i 0, i ${SWP_NOSIZE}|${SWP_NOMOVE})`
   ; Set the bitmap.
   System::Call `user32::LoadImage(i 0, t "$PLUGINSDIR\res.bmp", i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_CREATEDIBSECTION}|${LR_LOADFROMFILE}) i.s`
   Pop $hBitmap
   SendMessage $R1 ${STM_SETIMAGE} ${IMAGE_BITMAP} $hBitmap
   ; Set transparent backgrounds.
   !insertmacro SetTransparent $HWNDPARENT 3
   !insertmacro SetTransparent $HWNDPARENT 1
   !insertmacro SetTransparent $HWNDPARENT 2
   !insertmacro SetTransparent $HWNDPARENT 1034
   !insertmacro SetTransparent $HWNDPARENT 1037
   !insertmacro SetTransparent $HWNDPARENT 1038
   !insertmacro SetTransparent $HWNDPARENT 1028
   !insertmacro SetTransparent $HWNDPARENT 1256
   ; !insertmacro SetTransparent $HWNDPARENT 1045
   !insertmacro SetTransparent $HWNDPARENT 1035
   ; Remove unwanted controls.
   !insertmacro DestroyWindow  $HWNDPARENT 1256
   !insertmacro DestroyWindow  $HWNDPARENT 1028
   ; !insertmacro DestroyWindow  $HWNDPARENT 1039 
   !insertmacro DestroyWindow  $HWNDPARENT 1045     # dimm remove line from bottom
   ; !insertmacro DestroyWindow  $HWNDPARENT 1035
   ; !insertmacro DestroyWindow  $HWNDPARENT 1256

FunctionEnd


Function RefreshParentControls

   !insertmacro RefreshWindow  $HWNDPARENT 1037
   !insertmacro RefreshWindow  $HWNDPARENT 1038

FunctionEnd

Function WelcomePageShow

     # Sets background image
   System::Call `user32::LoadImage(i 0, t "$PLUGINSDIR\res.bmp", i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_CREATEDIBSECTION}|${LR_LOADFROMFILE}) i.s`
   Pop $hBitmap
   ; SendMessage $bitmapWindow ${STM_SETIMAGE} ${IMAGE_BITMAP} $hBitmap
      # Start solution
   SetCtlColors $mui.WelcomePage ${CTRL_COLOUR} transparent
   SetCtlColors $mui.WelcomePage.text ${CTRL_COLOUR} transparent
   SetCtlColors $mui.WelcomePage.title 0x333333 transparent
   !insertmacro DestroyWindow  $HWNDPARENT 1037
   !insertmacro DestroyWindow  $HWNDPARENT 1038
   !insertmacro DestroyWindow  $HWNDPARENT 1036 
   SetCtlColors $0 222425 transparent
   System::Call `user32::DestroyWindow(i $mui.WelcomePage.Image)`
   Call RefreshParentControls

FunctionEnd

   ; BrandingText ""
Free loaded resources.

Function .onGUIEnd

   ; Destroy the bitmap.
   System::Call `gdi32::DeleteObject(i s)` $hBitmap

FunctionEnd

--------------------------------------------------------------------------------------------------
Dummy section
--------------------------------------------------------------------------------------------------

Section "Dummy Section" SectionEnd

CSS

O01lI


O01lI


O01lI


O01lI


O01lI

O01lI

O01lI

O01lI