国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

搜索字符串在流中的位置

2019-11-18 18:24:38
字體:
來源:轉載
供稿:網友
(*//標題:搜索字符串在流中的位置說明:適用于文件搜索等設計:Zswang支持:wjhu111@21cn.com日期:2004-03-21//*)
(*//============================================================================設計思路:從流中將數據取到緩沖中再逐一對緩沖進行搜索============================================================================//*)
function ScanStream(mStream: TStream; mStr: string): Integer;const  cBufferSize = $8000;var  S: string;  T: string;  I: Integer;  L: Integer;begin  Result := -1;  if not Assigned(mStream) then Exit;  if mStr = '' then Exit;  L := Length(mStr);  mStream.Position := 0;  SetLength(S, cBufferSize);  T := '';  for I := 1 to mStream.Size div cBufferSize do begin    mStream.Read(S[1], cBufferSize);    Result := Pos(mStr, T + S) - 1; //保留上次搜索的尾部字符~~    T := Copy(S, cBufferSize - L, MaxInt);    if Result >= 0 then begin      Result := Result + PRed(I) * cBufferSize - Length(T);      Exit;    end;  end;  I := mStream.Size mod cBufferSize;  SetLength(S, I);  if I > 0 then begin    mStream.Read(S[1], I);    Result := Pos(mStr, T + S) - 1;    if Result >= 0 then begin      Result := Result + mStream.Size - I - Length(T);      Exit;    end;  end;end; { ScanStream }
//Exampleprocedure TForm1.Button1Click(Sender: TObject);var  vFileStream: TFileStream;begin  vFileStream := TFileStream.Create('C:/temp/temp.exe', fmShareDenyNone);  try    Label1.Caption := IntToStr(ScanStream(vFileStream, Edit1.Text));  finally    vFileStream.Free;  end;end;

上一篇:流的壓縮和解壓

下一篇:使用IntraWeb進行Web編程

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 钟祥市| 玛纳斯县| 平远县| 盐边县| 盐亭县| 永丰县| 东光县| 江西省| 甘肃省| 九龙坡区| 武清区| 田阳县| 雷山县| 四会市| 昭平县| 乐平市| 缙云县| 宜君县| 荆门市| 永康市| 甘谷县| 岳阳县| 阿荣旗| 新乡市| 翼城县| 布尔津县| 舒兰市| 陆良县| 商都县| 禄劝| 中阳县| 三台县| 赤壁市| 绥德县| 温宿县| 大关县| 来凤县| 个旧市| 涪陵区| 连平县| 高要市|