procedure LoadLogicalDrives(Strings: TStrings);
var
S: DWORD;
AllStrings, CurrentString: PChar;
begin
S := 255;
GetMem(AllStrings, Succ(S));
GetLogicalDriveStrings(S, AllStrings);
try
if AllStrings <> nil then
begin
CurrentString := AllStrings;
while True do
begin
Strings.Add(StrPas(CurrentString));
Inc(CurrentString, Succ(StrLen(CurrentString)));
if CurrentString[0] = #0 then
Break;
end;
end;
finally
FreeMem(AllStrings);
end;
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
var s : String; i, ii : integer;
begin
LoadLogicalDrives(Memo1.Lines);
Memo1.Text := StringReplace(memo1.Text, '\', #13,
[rfReplaceAll, rfIgnoreCase]);
//for i := 0 to Memo1.Lines.Count -1 do begin
//ii := Memo1.Lines.Count;
//end;
ComboBox1.Items.Assign(Memo1.Lines);
end;
Keine Kommentare:
Kommentar veröffentlichen