運行可執行文件
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;