unpacker我找到了我要找的东西,他应该在安装后解压缩文件 这是InnoUnzip.ZIP
我的安装程序文件夹如下所示:
我的代码:
[Setup]
AppName=My Program
AppVersion=1.0
DefaultDirName={pf}\My Program
DisableProgramGroupPage=yes
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output
[Files]
Source: "unzipper.dll"; Flags: dontcopy
Source: "MyProg.exe"; DestDir: "{app}"
Source: "Somefile.zip"; DestDir: "{app}"; AfterInstall: ExtractMe('{app}\Somefile.zip', '{app}');
[Icons]
Name: "{commonprograms}\My Program"; Filename: "{app}\MyProg.exe"
Name: "{commondesktop}\My Program"; Filename: "{app}\MyProg.exe"
[Code]
procedure unzip(src, target: AnsiString);
external 'unzip@files:unzipper.dll stdcall delayload';
procedure ExtractMe(src, target : AnsiString); - ERROR HERE!!!!!
begin
unzip(ExpandConstant(src), ExpandConstant(target));
end;
文字错误:“提取我”的原型无效
答案 0 :(得分:4)
跟进TLama关于DLL冗余的观点:只需在Inno Setup脚本中直接编码UnZip()
即可实现相同的效果。
const
SHCONTCH_NOPROGRESSBOX = 4;
SHCONTCH_RESPONDYESTOALL = 16;
procedure Unzip(ZipFile, TargetFolder: String);
var
ShellObj, SrcFile, DestFolder: Variant;
begin
ShellObj := CreateOleObject('Shell.Application');
SrcFile := ShellObj.NameSpace(ZipFile);
DestFolder := ShellObj.NameSpace(TargetFolder);
DestFolder.CopyHere(SrcFile.Items, SHCONTCH_NOPROGRESSBOX or SHCONTCH_RESPONDYESTOALL)
end;
procedure ExtractMe(src, target : String);
begin
// Add extra application code here, then:
Unzip(ExpandConstant(src), ExpandConstant(target));
end;
Inno Setup脚本代码或多或少与DLL相同......只是稍微短一点。
请注意,如果Zip或Destination文件夹不存在,NameSpace()
方法调用将返回Null
,CopyHere()
将失败,并且用户会看到一个粗鲁和令人困惑的对话框 - 所以最好在致电之前检查。
答案 1 :(得分:1)
将参数类型AnsiString更改为String。