问题
This is sort of a continuation of this question. I have a file that I want to include with my installation package (a .CHM help file) that I need to access during installation from code. It doesn't need to be installed to the user's machine. So I want to
- include the file in the installation package, probably uncompressed (so I guess I will do that with a [Files] ... external
flag).
- reference the file during installation with code like:
procedure HelpButtonOnClick (Sender: TObject) ;
var
ErrorCode : Integer ;
begin
ShellExecAsOriginalUser ('open', ExpandConstant ('{???}') + '\MyHelp.chm', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end ;
So can I reference the file before installation starts - i.e. before any files are copied to the user machine? How do I specify the path ExpandConstant ('{???}')
to the file? I have a help button on the wizard form that calls the above handler.
回答1:
This is easy. Just do
[Files]
Source: "MyHelp.chm"; Flags: dontcopy
[Code]
procedure HelpButtonOnClick(Sender: TObject);
var
ErrorCode: integer;
begin
ExtractTemporaryFile('MyHelp.chm');
ShellExecAsOriginalUser('', ExpandConstant('{tmp}\MyHelp.chm'), '', '',
SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
来源:https://stackoverflow.com/questions/6022588/innosetup-reference-a-file-from-code-before-the-installation-starts