Вниз
Скачать: CL | DM;

Поиск, оптимизация.   Найти похожие ветки 

← →
XenonXX ©   (2003-08-08 08:22) [0]

words:array of string;

....

procedure FindAll(dir,filename:string);
var data:TSearchRec;
s:string;
i:integer;
p:boolean;
l:TListItem;
icon:Hicon;
ic:Ticon;
t:pchar;
w:word;
begin
try
dir:=Slesh(dir);
s:=dir+"*";
inc(e);
if FindFirst(s,faAnyFile,data)=0 then
begin
repeat
if (data.Name<>".")and(data.Name<>"..") then
begin
s:=ExtractFileExt(data.Name);
if (length(s)<4)and((data.Attr and faDirectory) <> 0)
then begin
s:=dir+data.Name;
FindAll(s,filename)
end
else begin
if (pos(filename,data.Name)<>0)or(filename="") then
begin
p:=true;
IF high(words)<>-1 then
begin
Form1.Memo1.Clear;
Form1.Memo1.Lines.LoadFromFile(dir+data.Name);
for i:=low(words) to high(words) do
if pos(words[i],Form1.Memo1.Text)=0 then begin
Application.ProcessMessages;
p:=false;
break;
end;
end;
if p=true then begin
l:=form1.ListView1.Items.Add;
l.Data:=GetMemory(255);
{string}tt(l.Data^):=dir+data.Name;
l.Caption:=data.Name;
t:=pchar(dir+data.Name);
s:=rr("\"+ExtractFileExt(dir+data.Name),"");
s:=rr("\"+s+"\DefaultIcon","");
t:=pchar(copy(s,1,pos(",",s)-1));
s:=copy(s,pos(",",s)+1,length(s)-pos(",",s));
w:=StrToInt(s);
icon:=ExtractIcon(HInstance, t,w);
ic:=TIcon.Create;
ic.Handle:=icon;
l.ImageIndex:=form1.ImageList1.AddIcon(ic);
end;
end;
end;
end;
Application.ProcessMessages;
if stop then begin
FindClose(data);
exit;
( data) words:array of string;

....

procedure FindAll(dir,filename:string);
var data:TSearchRec;
s:string;
i:integer;
p:boolean;
l:TListItem;
icon:Hicon;
ic:Ticon;
t:pchar;
w:word;
begin
try
dir:=Slesh(dir);
s:=dir+"*";
inc(e);
if FindFirst(s,faAnyFile,data)=0 then
begin
repeat
if (data.Name<>".")and(data.Name<>"..") then
begin
s:=ExtractFileExt(data.Name);
if (length(s)<4)and((data.Attr and faDirectory) <> 0)
then begin
s:=dir+data.Name;
FindAll(s,filename)
end
else begin
if (pos(filename,data.Name)<>0)or(filename="") then
begin
p:=true;
IF high(words)<>-1 then
begin
Form1.Memo1.Clear;
Form1.Memo1.Lines.LoadFromFile(dir+data.Name);
for i:=low(words) to high(words) do
if pos(words[i],Form1.Memo1.Text)=0 then begin
Application.ProcessMessages;
p:=false;
break;
end;
end;
if p=true then begin
l:=form1.ListView1.Items.Add;
l.Data:=GetMemory(255);
{string}tt(l.Data^):=dir+data.Name;
l.Caption:=data.Name;
t:=pchar(dir+data.Name);
s:=rr("\"+ExtractFileExt(dir+data.Name),"");
s:=rr("\"+s+"\DefaultIcon","");
t:=pchar(copy(s,1,pos(",",s)-1));
s:=copy(s,pos(",",s)+1,length(s)-pos(",",s));
w:=StrToInt(s);
icon:=ExtractIcon(HInstance, t,w);
ic:=TIcon.Create;
ic.Handle:=icon;
l.ImageIndex:=form1.ImageList1.AddIcon(ic);
end;
end;
end;
end;
Application.ProcessMessages;
if stop then begin
FindClose(data);
exit;
end;
until FindNext(data)<>0;
end;
FindClose(data);

except
end;
end;


Вот, думаю поймете, но как сделать быстрее?


← →
Palladin ©   (2003-08-08 08:34) [1]

быстрее в FAQ


← →
NAlexey ©   (2003-08-08 09:10) [2]

Я не понял...


← →
[lamer]Barmaglot ©   (2003-08-08 09:24) [3]

Если по простому, то http://www.delphimaster.ru/cgi-bin/faq.pl?look=1&id=1015254946&n=19
Если хочешь быстрее и есть желание разбираться, то: http://www.delphimaster.ru/articles/shell.html



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.011 c
14-68458
Johnny Smith
2003-08-04 15:49
2003.08.21
Девушки-некрофилки. Миф или реальность? Разрешать или нет?


1-68287
Melamed
2003-08-06 22:01
2003.08.21
Вопрос по Tool API


1-68267
JS
2003-08-06 15:30
2003.08.21
Активизация приложения


14-68545
AHTOH
2003-08-04 22:22
2003.08.21
Почему hook и делают в основном в dll?


3-68210
Magic&Wizard
2003-07-28 11:24
2003.08.21
FireBird 1.5 vs InterBase 7.0




   Наверх