Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Laufwerkspfad (https://www.delphipraxis.net/331-laufwerkspfad.html)

Tpercon 4. Jul 2002 17:05

Den Beitrag von sakura habe ich gelesen, nur mir eht's um die GetLogicalDriveStrings Funktion.

Gruß

sakura 4. Jul 2002 17:15

Code:
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;
Ungetestet, sollte aber funktionieren.


:!: :!: Getestet und korrigiert!!!
:cat:

Tpercon 4. Jul 2002 18:07

Danke :!: :!:

Christian Seehase 5. Jul 2002 00:07

Moin Zusammen,

ich hätte da noch eine Variante:

Code:
procedure GetDriveLetterList(const p_slResult : TStrings);

var
  sWork : string;

begin
  sWork := StringOfChar(#00,105);
  GetLogicalDriveStrings(105,@sWork[1]);
  p_slResult.Text := StringReplace(sWork,':\'#00,#13#10,[rfReplaceall]);
end;
Dürfte allerdings nicht besonders schnell sein ;-)

sakura 5. Jul 2002 08:57

Hi Christian,

deine Variante ist vielleicht nicht besonders schnell, strotzt aber vor Einfachheit. :) Mir gefällt Deine Lösung sehr gut und für interaktive (Client-)Programme ist diese ausreichend schnell. ;)
:cat:


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:09 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz