Reputation: 1848
For a specific setup, i need the foldername (without the path) of the {app} constant with a inno-setup script.
So if in the wizard for the 'Select destination folder' the next folder is selected: C:\ProgramFiles\MyAppFolder, i need 'MyAppFolder' in a variable to use in the setup script.
Upvotes: 1
Views: 578
Reputation: 76733
If you want just to get the tail of the {app}
path, then you can call ExtractFileName
function for the path with removed backslash. That returns tail of a given path. In the following script the PathTail
var will contain the path tail unless the user selects a drive root (like e.g. C:\
). In that case, the PathTail
variable will be empty:
[Code]
function NextButtonClick(CurPageID: Integer): Boolean;
var
PathTail: string;
begin
Result := True;
if CurPageID = wpSelectDir then
begin
PathTail := ExtractFileName(RemoveBackslashUnlessRoot(ExpandConstant('{app}')));
MsgBox('PathTail: ' + PathTail, mbInformation, MB_OK);
end;
end;
Just to be clear, here are examples of what you'll get:
User selected PathTail contains
---------------------------- ----------------------------
C:\ ''
C:\Program Files\AppFolder\ 'AppFolder'
C:\Program Files\Subfolder\AppFolder\ 'AppFolder'
Upvotes: 1