[Delphi3] Laufwerksbezeichnung

Hi,
wie kann ich den Namen eines Laufwerks, also den Label, herausbekommen?
Mit FindFirst(„C:“, anyfile, … findet man die Datei nicht.

???

Chris

Hi,
wie kann ich den Namen eines Laufwerks,
also den Label, herausbekommen?
Mit FindFirst(„C:“, anyfile, … findet
man die Datei nicht.

Es gibt sicher bessere Methoden, aber probier mal

FindFirst(„C:\NUL“, anyfile, …)

(verwende ich immer in Batchdateien, um zu prüfen, ob ein Verzeichnis existiert).

Gruß
J.

Dafür gibt’s die API-Proc GetVolumeInformation.

BOOL GetVolumeInformation(

LPCTSTR lpRootPathName, // address of root directory of the file system
LPTSTR lpVolumeNameBuffer, // address of name of the volume
DWORD nVolumeNameSize, // length of lpVolumeNameBuffer
LPDWORD lpVolumeSerialNumber, // address of volume serial number
LPDWORD lpMaximumComponentLength, // address of system’s maximum filename length
LPDWORD lpFileSystemFlags, // address of file system flags
LPTSTR lpFileSystemNameBuffer, // address of name of file system
DWORD nFileSystemNameSize // length of lpFileSystemNameBuffer
);

Beispiel:

GetVolumeInformation(pChar(drvRoot), NIL, clDrvLabel, @VolSerial, MaxComp, Flags, NIL, clFSname);
SetLength(drvLabel, clDrvLabel);
SetLength(FSname, clFSname);
GetVolumeInformation(pChar(drvRoot), pChar(drvLabel), clDrvLabel, @VolSerial, MaxComp, Flags, pChar(FSname), clFSname);