Recommend this page to a friend! |
Classes of Christian Vigh | PHP List Windows Drives | README.md | Download |
|
DownloadINTRODUCTIONThe LogicalDrives class is a small utility class that works only on Windows platforms and allows you to query the logical disks that are declared on your system. It relies on the Windows Management Instrumentation interface (WMI) to retrieve logical drive information. DOCUMENTATIONDocumentation about WMI can be found here : https://msdn.microsoft.com/fr-fr/library/aa394582(v=vs.85).aspx.aspx "https://msdn.microsoft.com/fr-fr/library/aa394582(v=vs.85).aspx"). You can also get some information about the kind of data held in a LogicalDrive object here : https://msdn.microsoft.com/en-us/library/aa394173(v=vs.85).aspx.aspx "https://msdn.microsoft.com/en-us/library/aa394173(v=vs.85).aspx") (an object of class LogicalDrive maps directly to the WMI class Win32_LogicalDisk). Additionally, you will find a more generic WMI access implementation in PHP here : http://www.phpclasses.org/package/10001-PHP-Provides-access-to-Windows-WMI.html OVERVIEWBefore retrieving drive information, you need to have an instance of the LogicalDrives class :
The constructor takes no parameter. You can then call one of the methods implemented by the LogicalDrives class, such as GetAssignedDrives(), which retrieves the list of currently assigned logical drives :
the method will return an array of strings containing the drive letters that are currently assigned on your system, followed by a semicolon. You can go further and use them for indexing your LogicalDrives instance and get access to individual drive information, which will be presented as an object of class LogicalDrive ; the following example will display the volume name (or label) for each drive letter that has been assigned to your system :
} REFERENCELogicalDrives classThe LogicalDrives class is the main interface to access logical drive information. Since it implements the ArrayAccess interface, it can be accessed using either :
The class also implements the Iterator interface, meaning that you can retrieve individual drive information using foreach() constructs. ConstructorThe constructor takes no parameter and immediately retrieves information about all the logical disks that are defined on your system. GetAssignedDrives
Returns an array of strings representing the drive letters that are currently assigned on your system. Drive letters are systematically in uppercase and followed by a semicolon. GetNextAvailableDrive
Returns the next available drive letter. Drive letters are systematically in uppercase and followed by a semicolon. GetUnassignedDrives
Returns an array of strings representing the drive letters that are currently unassigned on your system (and therefore free for later use). Drive letters are systematically in uppercase and followed by a semicolon. LogicalDrive classThe LogicalDrive class encapsulates a Wmi WIN32\_LogicalDisk object for a given logical drive and implements all the properties that can be found in such an object (see https://msdn.microsoft.com/en-us/library/aa394173(v=vs.85).aspx.aspx "https://msdn.microsoft.com/en-us/library/aa394173(v=vs.85).aspx") for more information about this Wmi class, and about all the constants that are defined in the LogicalDrive class). You will find additional methods and constants that are described below : GetDriveType
Returns the drive type as a string ; it can be any of the following values, depending on the drive :
This method is designed only to provide a human-readable string describing the drive type. To programmatically determine the actual drive type, it is far better to use the DriveType property and compare it against one of the LogicalDrive::DRIVE\_TYPE\_\* constants. GetNetworkName
Returns an associative array containing the following entries :
Isxxx() classification functions
These functions check that the drive has the specified characteristic : compact disk, local to the system, network-mapped, ram disk or removable disk. NormalizeLetter
This function is mainly used internally, but has been made public in case of... It returns a "normalized" drive letter corresponding to the supplied input. The return value is always an uppercase letter followed by a semicolon. ArrayAccess and Iterator interfacesThe LogicalDrive class implements the ArrayAccess and Iterator interfaces, so that you can use for() or foreach() constructs to loop through the individual properties currently exposed by the underlying WMI object. ConstantsAll the constants described below are documented here : https://msdn.microsoft.com/en-us/library/aa394173(v=vs.85).aspx.aspx "https://msdn.microsoft.com/en-us/library/aa394173(v=vs.85).aspx")
|