Re: Get a file's version in PHP
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Get a file's version in PHP

From: Peter van Schie <vanschie.peter@gmail.com>
Date: Sun Oct 30 2005 - 14:32:17 CET

Another option, without using COM, would be to open the binary file and
search for the pattern F\0i\0l\0e\0V\0e\0r\0s\0i\0o\0n\0\0\0\0\0
The version is right behind that string:

$strFile = "c:\\my.exe";
$fpFile = fopen($strFile, "rb");
$strFileContent = fread($fpFile, filesize($strFile));
fclose($fpFile);

$strTagBefore = 'F\0i\0l\0e\0V\0e\0r\0s\0i\0o\0n\0\0\0\0\0';
$strTagAfter = '\0\0';
if (preg_match("/$strTagBefore(.*?)$strTagAfter/", $strFileContent,
$arrMatches))
{
        print_r($arrMatches);
}

HTH.
Peter.

-- 
http://www.phpforums.nl
Received on Mon Nov 21 02:52:59 2005