运行可执行文件
var
FileName, Params: String;
ResultCode: Integer;
begin
FileName := ExpandConstant('{app}/application.exe');
Params := ExpandConstant('-x " ');
Exec(FileName, FileName + ' ' + Params, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
or like this:
var
ErrorCode: Integer;
begin
ShellExec('open', 'http://www.163.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
Inno Setup中进行MD5的校验
var
ComMD5: Integer;
FileExit: Boolean;
begin
if CurPageID = wpSelectDir then
begin
FileExit := FileExists(ExpandConstant('{app}/abcde.exe'));//判断文件 abcde.exe 是否存在于安装目录下
if FileExit = false then begin//如果未找到
MsgBox('未在该文件夹中搜索到 abcde V0.0.1'#13#13'请选择正确的目录!', mbInformation, MB_OK);
Result := False;
end else if FileExit = True then begin
ComMD5 := CompareStr(GetMD5OfFile(ExpandConstant('{app}/ abcde.exe')), '56faga4457fa87fda4654f5645afdafddafdaf');//计算文件 MD5 值,并把结果返回给 ComMD5,0 代表相等
if ComMD5 <> 0 then begin//如果文件不相同
MsgBox('文件版本不对或文件已被应用过补丁!'#13#13'请安装正确的版本或退出当前安装程序!', mbInformation, MB_OK);
Result := False;
end else
Result := True;
end;
end
else
Result := True;
end;