Форум: "Основная";
Текущий архив: 2002.10.10;
Скачать: [xml.tar.bz2];
ВнизГлобальный поиск Найти похожие ветки
← →
Gayrus (2002-09-28 14:28) [0]Как осуществить глобальный поиск( по всему диску), а то этот код ищет только в данной папке:
var sr:TSearchRec;
...
If FindFirst("*",faDirectory,sr)=0 then repeat
ListBox1.Items.Add(sr.Name);
until FindNext(sr)<>0;
FindClose(sr)
← →
TTCustomDelphiMaster (2002-09-28 14:42) [1]http://delphibase.endimus.com/?action=viewtopic&topic=filenames
← →
Anatolyk (2002-10-02 10:37) [2]//Привожу полностью отбрось все лишнее некоторые переменные определены на верхнем уровне
//ето ищет определенные файлы и готовит CFG для другой программы
//Очевидно, существует более красивый подход
procedure TForm1.Directory(Root: String);
var
sr, ExecutableFile: TSearchRec;
FileAttrs, i, ipos: Integer;
S: String;
tmpStr: Pchar;
dir, base: String;
NoFilesFound : Boolean;
begin
ChDir(Root);
FileAttrs := faAnyFile;
if FindFirst("*.*", FileAttrs, sr) = 0 then
begin
repeat
if (sr.Attr and FileAttrs) = sr.Attr then
begin
if not((Sr.Name = ".") or (Sr.Name = "..")) then
if (sr.Attr and faDirectory) = faDirectory then
begin
Directory(Root+ "\" + sr.Name);
ChDir("..");
end
else
begin
//содержит ли строка ИНИ-файл?
ipos := pos(".INI",UpperCase(sr.Name));
if (ipos>0) AND (POS(UpperCase(SR.NAME),AVAILABLEINI)>0) then
begin
{ПРОВЕРКА НА upgrade и DEMO}
NoFilesFound := False;
If FindFirst("..\*32.EXE",faAnyFile,ExecutableFile) = 0 then
begin
//Пропускаем все Up* и Demo (на всякий случай)
while (pos("UP",UpperCase(ExecutableFile.Name))>0)
or (pos("DEM",UpperCase(ExecutableFile.Name))>0)
or (pos("_D",UpperCase(ExecutableFile.Name))>0)
or (pos("D.",UpperCase(ExecutableFile.Name))>0) Do
begin
if FindNext(ExecutableFile)<>0 then {Error ocuured}
begin
NoFilesFound := True;
break;
end;
end;
FindClose(ExecutableFile);
if NoFilesFound Then continue;
FileToFind := IncludeTrailingPathDelimiter(ExtractfilePath(Root)) + ExecutableFile.Name;
end;
{генерируем base.cfg}
//1. Id базы
S:= "";
tmpstr := pchar(sr.name);
for i:=1 to ipos-1 do
begin
S := S + tmpstr[i-1];
end;
base := S;
S := "";
tmpStr := pchar(Root);
for i:=1 to (StrLen(pchar(tmpStr)) - ipos) do
begin
S := S + tmpstr[i-1];
end;
dir := S;
//3. Строка для Base.CFG
if pos("Демо:", PossibleBaseName(Root + "\" + sr.Name)) = 0 then
begin
S := IntToStr(BaseCfgCount)+
" " + base +
" " + dir +
" " + PossibleBaseName(Root + "\" + sr.Name) +
" DIR=" + dir;
//4. Увеличиваем счетчик строк
BaseCfgCount := BaseCfgCount + 1;
tmpstr := pchar(s);
CharToOEM(tmpstr,tmpstr);
WriteLn(CfgFileVar,tmpstr);
if LMDCheckBox8.Checked then
begin
... end;
end;
Flush(CfgFileVar);
end;
end;
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
end;
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2002.10.10;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.007 c