Bonjour à tous
J'ai un bouton qui permet de lister les fichiers d'un répertoire.
j'ai un second bouton qui listes les disques durs.

sans windows dans les uses, message d'erreur (unit1.pas(57,7) Error: Identifier not found "GetDriveType").
avec windows dans les uses, message d'erreur (func.inc(185,10) Hint: Found declaration: FindClose(QWord):LongBool;)

mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
procedure TForm1.Button1Click(Sender: TObject);
var
searchResult : TSearchRec;
path : string;
begin
path := 'd:\';
if FindFirst(path + '*', faDirectory, searchResult) = 0 then
begin
repeat
listbox1.items.Add(searchResult.Name);
until FindNext(searchResult) <> 0;
FindClose(searchResult);
end;
end;
 
procedure TForm1.Button2Click(Sender: TObject);
var
i:char;
begin
 for i:='A' to 'Z' do
   begin
   if GetDriveType(PChar(i+':\'))<>1 then
     listbox1.items.Add(i+':\');
    end;
end;