Inno Setup - Conditional DisableDirPage

Using Inno Setup 5.5.2 I am trying to conditionally skip the selection of the installation directory depending on the availability of the path. In particular, if the "D: \" drive is available, I want to install it in a predefined location without prompts, and if it is not available, specify prompts with a reasonable default value.

I have code that works for DefaultDirName but not for DisableDirPage :

 [Code] const DefaultDrive = 'D:\'; AppFolder = 'SomeDir'; function GetDefaultDir( Param: String ) : String; begin if DirExists( DefaultDrive ) then begin Result := DefaultDrive + AppFolder; end else begin Result := ExpandConstant('{pf}\') + AppFolder; end; end; function DefaultDirValid( Param: String ) : Boolean; begin Result := DirExists( DefaultDrive ); end; [Setup] ; Works as expected DefaultDirName={code:GetDefaultDir} ... ; Compiler Error - Value of [Setup] section directive "DisableDirPage" is invalid. DisableDirPage={code:DefaultDirValid} 

I tried using functions for DisableDirPage that return yes and no strings, as well as integers from 0 and 1. I also tried to include a call to DirExists . All of them threw the same compiler error.

My best guess is that this is because DisableDirPage accepts a tri-state of yes, no, or auto. Is there a specific type associated with the tri-state logic that needs to be returned? Inno's help on Scripted Constants only says:

The called function should have 1 String parameter named Param and should return a String or Boolean value depending on where the constant is used.

+4
source share
1 answer

Using the ShouldSkipPage event handler, you can skip the directory selection page if there is a permanent DefaultDrive path with the following script

 [Setup] AppName=My Program AppVersion=1.5 DefaultDirName={code:GetDefaultDir} [Code] const DefaultDrive = 'D:\'; AppFolder = 'Some Folder'; function GetDefaultDir(Param: string): string; begin Result := DefaultDrive + AppFolder; if not DirExists(DefaultDrive) then Result := ExpandConstant('{pf}\') + AppFolder; end; function ShouldSkipPage(PageID: Integer): Boolean; begin Result := (PageID = wpSelectDir) and DirExists(DefaultDrive); end; 
+6
source

Source: https://habr.com/ru/post/1439170/


All Articles