// Declaration: getlogicaldrivestrings (nbufferlength: DWORD; {buffer size} lpbuffer: pansichar {buffer}): DWORD; // The buffer result is stored as follows: for example, drive a is represented as a: \ separated by an empty character, followed by backward; // Therefore, each drive occupies 4 bytes.
// Example: Procedure tform1.formcreate (Sender: tobject); var pstr: pchar; drivearr: array [0 .. 4*26] of char; {4 bytes per drive, up to 26 drives} begin getlogicaldrivestrings (sizeof (drivearr), drivearr); {function call is that simple} pstr: = drivearr; {because pstr ends with #0, it now points to the first 4 bytes} memo1.clear; {clear memo} while pstrnil do begin memo1.lines. add (pstr); Inc (pstr, strlen (pstr) + 1); {the string pointer can be operated, which is equivalent to moving the pointer to four positions, pointing to the next} If (byte (pstr [0]) = 0) Then pstr: = nil; {if the first character of the next row is null, it means no more, while waiting for nil to terminate} end;
//: