Delphi or INNO 版本号比较方法 版本差

{替换字符串}
function StringReplace(const S, OldPattern, NewPattern: string): string;
var
  SearchStr, Patt, NewStr: string;
  Offset: Integer;
begin
  SearchStr := S;
  Patt := OldPattern;
  NewStr := S;
  Result := ‘‘;
  while SearchStr <> ‘‘ do
  begin
    Offset :=Pos(Patt, SearchStr);
    if Offset = 0 then
    begin
      Result := Result + NewStr;
      Break;
    end;
    Result := Result + Copy(NewStr, 1, Offset - 1) + NewPattern;
    NewStr := Copy(NewStr, Offset + Length(OldPattern), MaxInt);
    SearchStr := Copy(SearchStr, Offset + Length(Patt), MaxInt);
  end;
end;

//版本号比较{返回版本差}
function CompareVersion(New, Old: string): Integer;
var
  iNew,iOld:Integer;
begin
  Result := -1;
  iNew := StrToIntDef(StringReplace(New,.,‘‘),-1);
  if iNew = -1 then exit;
  iOld := StrToIntDef(StringReplace(Old,.,‘‘),-1);
  if iOld = -1 then exit;
  Result := iNew - iOld;
end;

 

Delphi or INNO 版本号比较方法 版本差

上一篇:20150216—winform中的DataGridView


下一篇:通过SSIS监控远程服务器Windows服务并发送邮件报警!