Example – How to use System_WinDrives

Using System_WinDrives

General usage

require_once 'System/WinDrives.php';

//if you want to read the names, pass "true" as first parameter
//this may crash your php.exe, so it's disabled by default
$wd = new System_WinDrives(false);

'API available: ';
$wd->isApiAvailable() ? 'yes' 'no';

$arInfo $wd->getDrivesInformation();
foreach (
$arInfo as $strDrive => $objInfo) {
$strDrive "\r\n";
'   Type: ' $objInfo->type "\r\n";
'   Type title: ' .  $objInfo->typetitle "\r\n";
'   Name: ' $objInfo->name "\r\n";

At first, you need to instantitiate a new System_WinDrives object. You can pass "true" as parameter to enable hard disk names, but that can crash PHP and is disabled by default.

The next thing to do is checking if the class can be used. That depends on the available extensions (win32api on PHP4, and php_ffi on PHP5). If the isApiAvailable method returns true, everything is ok.

Now that everything is ok, you can read the driver information via getDrivesInformation and display the output.

In case the API is not available, the method tries to guess the drive list by checking if the root directories exist.

Enumerating drives on Windows systems (Previous) Constants defined and used in System_WinDrives (Next)
Last updated: Mon, 23 Jan 2017 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.