Forum Moderators: coopster
However, to recognize which disk is in a DVD drive, I want to read the volume name from the DVD, and I have not figured that out. Maybe I'm using the wrong keywords, but I'm not locating any help with Google.
By volume name I mean that which appears in the title bar of a directory window of a DVD or CD drive. It also appears in a Windows directory of "My Computer" next to the drive name. When the drive is empty, it appears as, say, 'DVD Drive (V:)' and when a DVD disk is put in the drive, it instead shows 'This_Disc_Name (V:)' It is the 'This_Disc_Name that I would like to pull into a variable in a PHP script.
The answer is on the php documentation page for shell_exec, and refers to Windows (I'm using the IIS).
[us2.php.net...]
<?php
function GetVolumeLabel($drive) {
// Try to grab the volume name
if (preg_match('#Volume in drive [a-zA-Z]* is (.*)\n#i', shell_exec('dir '.$drive.':'), $m)) {
$volname = ' ('.$m[1].')';
} else {
$volname = '';
}
return $volname;
}
print GetVolumeLabel("c");
?>