Показать сообщение отдельно
  #2  
Старый 06.12.2008, 22:09
Drozh Drozh вне форума
Активный
 
Регистрация: 12.06.2008
Сообщения: 313
Репутация: 40
По умолчанию

Так
Код:
function MatchAttrs(flags, attrs: DWORD): Boolean;
begin
  MatchAttrs := (flags and attrs) = flags;
end;

function SearchInFolder(folder: String; names: TStrings): Boolean;
var
 hSearch: Thandle;
 FindData: WIN32_FIND_DATA;
 strSearchPath: String;
 bRes: Boolean;
begin
 strSearchPath := folder + '\*.*';
 bRes:= false;

 hSearch := FindFirstFile(PAnsiChar(strSearchPath), FindData);
  if hSearch <> INVALID_HANDLE_VALUE then
   repeat
    if (String(FindData.cFileName) <> '..') and
       (String(FindData.cFileName) <> '.') then
     if MatchAttrs(FILE_ATTRIBUTE_DIRECTORY, FindData.dwFileAttributes) then
     begin
      names.Add(FindData.cFileName);
      bRes:=True;
     end;
    until FindNextFile(hSearch, FindData) = False;

 SearchInFolder := bRes;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 if not SearchInFolder('C:\Windows', Memo1.Lines) then
  ShowMessage('Error');
end;
Ответить с цитированием