本文整理匯總了PHP中COM::regRead方法的典型用法代碼示例。如果您正苦於以下問題:PHP COM::regRead方法的具體用法?PHP COM::regRead怎麽用?PHP COM::regRead使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類COM
的用法示例。
在下文中一共展示了COM::regRead方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: detectInkscapePath
function detectInkscapePath()
{
if (detectOS(HK_OS_WINDOWS)) {
// automatic attempt to recognize Inkscape path for Windows
$inkPath = "Inkscape";
$inkBin = "inkscape.com";
// try standard locations
if (isset($_SERVER['ProgramFiles(x86)']) && file_exists($tryPath = "{$_SERVER['ProgramFiles(x86)']}\\{$inkPath}\\{$inkBin}")) {
return $tryPath;
}
if (isset($_SERVER['ProgramW6432']) && file_exists($tryPath = "{$_SERVER['ProgramW6432']}\\{$inkPath}\\{$inkBin}")) {
return $tryPath;
}
// try to read from registry
if (!extension_loaded('com_dotnet')) {
dl('php_com_dotnet.dll');
}
$sh = new COM('WScript.Shell');
$checkKeys = ["HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\inkscape.exe\\", "HKCR\\inkscape.svg\\shell\\open\\command\\"];
foreach ($checkKeys as $rk) {
try {
$regRead = $sh->regRead($rk);
// no need to check if read passed, because if not, the rest of block won't be executed
$regRead = str_replace('%1', '', $regRead);
$tryPath = dirname(trim($regRead, '" ')) . "\\{$inkBin}";
if (file_exists($tryPath)) {
return $tryPath;
}
} catch (Exception $e) {
}
}
return '';
// not found
} else {
// automatic attempt to recognize Inkscape path for other systems
if ($shOut = shell_exec('command -v inkscape')) {
return trim($shOut);
}
// passes if Inkscape is within default path
// try standard location
$tryPath = '/usr/bin/inkscape';
if (file_exists($tryPath)) {
return $tryPath;
}
return '';
// not found
}
}
示例2: readRegistry
/**
* Function reads the registry value of the specified path
* @param <string> $registryPath Path of the registry value to be read
* @return <string> Registry value
* @category Extra
* <code>
* $result = Extra::readRegistry('registry\\path');
* </code>
*/
function readRegistry($registryPath)
{
try {
$Wshshell = new COM('WScript.Shell');
$data = $Wshshell->regRead($registryPath);
return $data;
} catch (Exception $err) {
return $err->getMessage();
}
}
示例3: read
public function read($key)
{
return $this->shell->regRead($key);
}