本文整理汇总了PHP中COM::RegWrite方法的典型用法代码示例。如果您正苦于以下问题:PHP COM::RegWrite方法的具体用法?PHP COM::RegWrite怎么用?PHP COM::RegWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COM
的用法示例。
在下文中一共展示了COM::RegWrite方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeRegistry
/**
* Function writes a value to the registry
* @param <string> $folder Folder to save the registry value in
* @param <string> $key Key to write to the registry
* @param <string> $value Value to write to the registry
* @param <string> $type (optional) Type of registry that is being used
* @return <boolean> Whether registry was successfully written to or not
* @category Extra
* <code>
* $result = Extra::writeRegistry('registry\\path', 'key', 'value');
* </code>
*/
function writeRegistry($folder, $key, $value, $type = 'REG_SZ')
{
try {
$WshShell = new COM("WScript.Shell");
$registry = "HKEY_LOCAL_MACHINE\\SOFTWARE\\" . $folder . "\\" . $key;
$result = $WshShell->RegWrite($registry, $value, $type);
echo "Entry is Successfully written at : " . $registry;
return $result;
} catch (Exception $err) {
return $err->getMessage();
}
return FALSE;
}
示例2: phpreg
function phpreg()
{
$shell1 = new COM("wscript.shell") or die("require windows host");
$action = isset($_POST['action']) ? $_POST['action'] : '';
echo '<div class="actall"><h5>Windows注册表读写</h5></div>';
print <<<END
<TR><form action="" method="post">
<div class="actall"><TD WIDTH=100 VALIGN=TOP ALIGN=CENTER>
路径:<input type="hidden" name="action" value="读取">
<input type="text" name="rpath" value="{$rpath}" size="70">
<input class="bt" type="submit" value="读取"></form><br></TD></TR></div>
END;
$rpath = isset($_POST['rpath']) ? $_POST['rpath'] : '';
$rpath = str_replace("\\\\", "\\", $rpath);
if ($action == "read") {
$out = $shell1->RegRead($rpath);
echo '<pre>' . var_dump($out) . '</pre>';
}
print <<<END
<TR><form action="" method="post">
<div class="actall"><TD WIDTH=100 VALIGN=TOP ALIGN=CENTER>位置:<input type="text" name="wpath" value="{$wpath}" size="70"><BR><br>
类型:<input type="text" name="wtype" value="{$wtype}" size="20"> 值:<input type="text" name="wvalue" value="{$wvalue}" size="30">
<input type="hidden" name="action" value="write"><input class="bt" type="submit" value="写入"></form></TD></TR></div>
END;
$wpath = isset($_POST['wpath']) ? $_POST['wpath'] : '';
$wpath = str_replace("\\\\", "\\", $wpath);
$wtype = isset($_POST['wtype']) ? $_POST['wtype'] : '';
$wvalue = isset($_POST['wvalue']) ? $_POST['wvalue'] : '';
if ($action == "write") {
$shell1->RegWrite($wpath, $wvalue, $wtype);
}
print <<<END
<TR><form action="" method="post">
<div class="actall"><TD WIDTH=100 VALIGN=TOP ALIGN=CENTER>
位置:<input type="hidden" name="action" value="del">
<input type="text" name="dpath" value="{$dpath}" size="70">
<input class="bt" type="submit" value="删"></form></TD></TR></div>
END;
$dpath = isset($_POST['dpath']) ? $_POST['dpath'] : '';
$dpath = str_replace("\\\\", "\\", $dpath);
if ($action == "del") {
$out = $shell1->RegDelete($dpath);
}
}
示例3: write
public function write($key, $value, $type = "REG_EXPAND_SZ")
{
try {
$result = $this->shell->RegWrite($key, $value, $type);
return $result;
} catch (Exception $e) {
echo "Write Registry Key : {$key} error." . PHP_EOL;
echo "Exception Code " . $e->getCode() . PHP_EOL;
echo "Exception Message : " . $e->getMessage() . PHP_EOL;
}
return false;
}