Author: Tomas Rutkauskas
How to show the buffer contents of the GetLogicalDriveStrings function in a TMemo
Answer:
1 procedure GetLogicalDrives(aList: TStrings);
2 var3 buff: PChar;
4 size, i, j: DWORD;
5 begin6 {first we get the number of bytes required}7 j := GetLogicalDriveStrings(0, PChar(@j));
8 size := j;
9 Getmem(buff, size);
10 try11 j := GetLogicalDriveStrings(size, buff);
12 for i := 0 to j - 1 do13 if (buff[i] = #0) then14 buff[i] := #13;
15 aList.text := buff;
16 finally17 Freemem(buff, size);
18 end;
19 end;