Re: Disk serial number

From: Date: Fri, 23 Jul 2004 10:08:22 +0000
Subject: Re: Disk serial number
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-191623@lists.php.net to get a copy of this message
I receive an error: "Warning: dl(): Not supported in multithreaded Web servers - use extension statements in your php.ini " "Tom Rogers" <trogers@kwikin.com> wrote in message news:1062639975.20040723102239@kwikin.com... > Hi, > > Friday, July 23, 2004, 8:26:56 AM, you wrote: > R> Hi, > R> Is there a way to get with PHP script ( maybe with some module) serial > R> number of the hard disk? > > R> Thanks in advance! > > On windows you can use the win32api like this: > > <?php > dl("php_w32api.dll"); > $api =& new win32; > $api->registerfunction("long GetLastError > Alias GetError () > From kernel32.dll"); > $api->registerfunction("long GetVolumeInformationA > Alias GetVolumeInformation > (string a, string &b, int c, int &d, int &e, int &f, string &g, int h) > From kernel32.dll"); > > $drive = "C:\\"; > $serialNo = 0; > $MaximumComponentLength = 0; > $FileSystemFlags = 0; > $VolumeNameSize = 260; > $VolumeNameBuffer = str_repeat("\0", $VolumeNameSize); > $FileSystemNameSize = 260; > $FileSystemNameBuffer = str_repeat("\0", $FileSystemNameSize); > if(!$result = $api->GetVolumeInformation( > $drive, > $VolumeNameBuffer, > $VolumeNameSize, > $serialNo, > $MaximumComponentLength, > $FileSystemFlags, > $FileSystemNameBuffer, > $FileSystemNameSize)){ > $error = $api->getError(); > echo $drive.' Oops error: '.$error."\n"; > } > echo "Drive $drive (".trim($VolumeNameBuffer).") Serial number $serialNo\n"; > ?> > > (The stock win32api dll will probably crash with that many variables so > let me know if you want a working version.) > > -- > regards, > Tom

« previous php.general (#191623) next »