/**
* PHP 读取 exedll 文件版本号
*
* @param $filename 目标文件
* @return 读取到的版本号
*/
function getFileVersion($filename)
{
$fileversion = '';
$fpFile = @fopen($filename, "rb");
$strFileContent = @fread($fpFile, filesize($filename));
fclose($fpFile);
if($strFileContent)
{
$strTagBefore = 'FileVersion'; // 如果使用这行,读取的是 FileVersion
// $strTagBefore = 'ProductVersion'; // 如果使用这行,读取的是 ProductVersion
$strTagAfter = '';
if (preg_match("/$strTagBefore(.*?)$strTagAfter/", $strFileContent, $arrMatches))
{
if(count($arrMatches) == 2)
{
$fileversion = str_replace("", '', $arrMatches[1]);
}
}
}
return $fileversion;
}
PHP 读取 exe 或 dll 版本号函数
未经允许不得转载:码农资源网 » PHP 读取 exe 或 dll 版本号函数