Show the buffer contents of the GetLogicalDriveStrings function in a TMemo (Views: 32)
Problem/Question/Abstract: How to show the buffer contents of the GetLogicalDriveStrings function in a TMemo Answer: procedure GetLogicalDrives(aList: TStrings); var buff: PChar; size, i, j: DWORD; begin {first we get the number of bytes required} j := GetLogicalDriveStrings(0, PChar(@j)); size := j; Getmem(buff, size); try j := GetLogicalDriveStrings(size, buff); for i := 0 to j - 1 do if (buff[i] = #0) then buff[i] := #13; aList.text := buff; finally Freemem(buff, size); end; end; |