I've been reading through Inno Setup documentation and got confused about why do we specify the path in ExtractTemporaryFiles
function if according to the documentation it extracts the files matching the wildcard specified by Pattern from the [Files]
section to a temporary directory.? If we have this Source: "Readme.txt"; Flags: dontcopy
in the [Files]
section why do we type ExtractTemporaryFiles('{tmp}\Readme.txt')
in the [Code]
section? Is that a mistake or I just don't understand how this function works? The same applies to the ExtractTemporaryFile
procedure.
Here's the code from ExtractTemporyFile
page:
[Files]
Source: "Readme.txt"; Flags: dontcopy noencryption
[Code]
function InitializeSetup: Boolean;
var
S: AnsiString;
begin
// Show the contents of Readme.txt (non Unicode) in a message box
ExtractTemporaryFile('Readme.txt');
if LoadStringFromFile(ExpandConstant('{tmp}\Readme.txt'), S) then
begin
MsgBox(S, mbInformation, MB_OK);
end;
Result := True;
end;
And here's the code from ExtractTemporaryFiles
page:
[Files]
Source: "Readme.txt"; Flags: dontcopy
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
[Code]
function InitializeSetup: Boolean;
var
S: AnsiString;
ResultCode: Integer;
begin
// Show the contents of Readme.txt (non Unicode) in a message box
ExtractTemporaryFiles('{tmp}\Readme.txt');
if LoadStringFromFile(ExpandConstant('{tmp}\Readme.txt'), S) then
begin
MsgBox(S, mbInformation, MB_OK);
end;
// Extract all MyProg files and launch it. Note how {app} is left unexpanded.
ExtractTemporaryFiles('{app}\MyProg.*');
ExecAsOriginalUser(ExpandConstant('{tmp}\')+'{app}\MyProg.exe', '', '',
SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
Result := True;
end;
In the first case we have:
[Files]
Source: "Readme.txt"; Flags: dontcopy noencryption
[Code]
ExtractTemporaryFile('Readme.txt');
And in the second one we have:
[Files]
Source: "Readme.txt"; Flags: dontcopy
[Code]
ExtractTemporaryFiles('{tmp}\Readme.txt');
What's the difference between those two? (noencryption
flag does not count)
Why do we need to specify the {tmp}
constant in the second case if we already extracting from there? In order to be able to use those methods correctly I need to have a clear understanding of the syntax.
With ExtractTemporaryFiles
(contrary to ExtractTemporaryFile
), you need to use the full value of the DestDir
parameter (in addition to the filename) to select the correct copy of the file, in case there are multiple files with the same name in the installer. On the contrary, ExtractTemporaryFile
will always extract the first file with the given name.
So having this:
[Files]
Source: "one\readme.txt"; DestDir: "{app}\one"
Source: "two\readme.txt"; DestDir: "{app}\two"
Source: "three\readme.txt"; Flags: dontcopy
one\readme.txt
, use: ExtractTemporaryFiles('{app}\one\readme.txt')
two\readme.txt
, use: ExtractTemporaryFiles('{app}\two\readme.txt')
three\readme.txt
, use: ExtractTemporaryFiles('{tmp}\readme.txt')
Flags: dontcopy
implies DestDir: {tmp}
for some reason)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With