...den Laufwerk Name ermitteln?

Autor: Rainer Kümmerle
Homepage: http://www.thinklazy.de

Kategorie: System

function GetVolumeName(DriveLetter: Char): string;
var
  
dummy: DWORD;
  buffer: array[0..MAX_PATH] of Char;
  oldmode: LongInt;
begin
  
oldmode := SetErrorMode(SEM_FAILCRITICALERRORS);
  try
    
GetVolumeInformation(PChar(DriveLetter + ':\'),
                         buffer,
                         SizeOf(buffer),
                         nil,
                         dummy,
                         dummy,
                         nil,
                         0);
    Result := StrPas(buffer);
  finally
    
SetErrorMode(oldmode);
  end;
end;

// Example, Beispiel:

procedure TForm1.Button1Click(Sender: TObject);
begin
  
Caption := GetVolumeName('c');
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base