欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解JavaScript修改注冊(cè)表的方法

 更新時(shí)間:2020年01月05日 10:20:01   投稿:mrr  
這篇文章主要介紹了詳解JavaScript修改注冊(cè)表的方法,本實(shí)例主要通過(guò)WshShell 對(duì)象的相關(guān)方法實(shí)現(xiàn),需要的朋友可以參考下

本實(shí)例主要通過(guò)WshShell 對(duì)象的相關(guān)方法實(shí)現(xiàn)。WshShell對(duì)象是WSH(WSH是Windows ing Host的縮寫(xiě),內(nèi)嵌于Windows操作系統(tǒng)中的腳本語(yǔ)言工作環(huán)境)的內(nèi)建對(duì)象,主要負(fù)責(zé)程序的本地運(yùn)行、處理注冊(cè)表、創(chuàng)建快捷方式、獲取系統(tǒng)文件夾信息及處理環(huán)境變量等工作。 WshShell 對(duì)象的相關(guān)方法如表11.1所示。

本實(shí)例中主要應(yīng)用了 RegWrite方法,下面將對(duì)該方法進(jìn)行詳細(xì)介紹。

RegWrite方法用于在注冊(cè)表中設(shè)置指定的鍵或值,其語(yǔ)法格式如下:

WshShell.RegWrite strName, anyValue, [strType]

參數(shù)說(shuō)明

l     strName:用于指定注冊(cè)表的鍵或值,若strName以一個(gè)反斜杠 (在 中為//) 結(jié)束,則該方法設(shè)置鍵,否則設(shè)置值。strName 參數(shù)必須以根鍵名“HKEY_CURRENT_USER”、 “HKEY_LOCAL_MACHINE”、“HKEY_CLASSES_ROOT”、“HKEY_USERS”或 “HKEY_CURRENT_CONFIG”開(kāi)頭。

l     AnyValue:用于指定注冊(cè)表的鍵或值的值。當(dāng)strType為REG_SZ或REG_EXPAND_SZ時(shí),RegWrite方法自動(dòng)將 anyValue轉(zhuǎn)換為字符串。若strType為REG_DWORD,則anyValue被轉(zhuǎn)換為整數(shù)。若strType為REG_BINARY,則 anyValue必須是一個(gè)整數(shù)。

l     StrType:用于指定注冊(cè)表的鍵或值的數(shù)據(jù)類型。RegWrite方法支持的數(shù)據(jù)類型為REG_SZ、REG_EXPAND_SZ、 REG_DWORD和REG_BINARY。其他的數(shù)據(jù)類型被作為strType傳遞,RegWrite 返回 E_INVALIDARG。

實(shí)現(xiàn)過(guò)程

(1)編寫(xiě)自定義 函數(shù)PageSetup_del()和PageSetup_set(),用于實(shí)現(xiàn)清空頁(yè)眉頁(yè)腳和恢復(fù)頁(yè)眉頁(yè)腳的功能。具體代碼如下:

< language=" "> 
 var HKEY_RootPath="HKEY_CURRENT_USER//Software//Microsoft//Internet Explorer//PageSetup//"; function PageSetup_del()
{  
 //清空頁(yè)眉頁(yè)腳
 try
{ 
 var WSc=new ActiveX ("W .Shell");  HKEY_Key="header"; 
 WSc.RegWrite(HKEY_RootPath+HKEY_Key,"");  HKEY_Key="footer"; 
 WSc.RegWrite(HKEY_RootPath+HKEY_Key,""); 
}catch(e){} 
} 
function PageSetup_set()
{ 
 //恢復(fù)頁(yè)眉頁(yè)腳 
 try{ 
 var WSc=new ActiveX ("W .Shell");  HKEY_Key="header"; 
 WSc.RegWrite(HKEY_RootPath+HKEY_Key,"&w&b頁(yè)碼,&p/&P");  
HKEY_Key="footer"; 
 WSc.RegWrite(HKEY_RootPath+HKEY_Key,"&u&b&d"); 
 }catch(e){} 
} 
</ >

(2)建立HTML的 標(biāo)簽,調(diào)用WebBrowser控件,代碼如下:

< id="WebBrowser" classid="ClSID:8856F961-340A-11D0-A96B-00C04Fd705A2" width="0" height="0">

</ >

(3)創(chuàng)建“清空頁(yè)眉頁(yè)腳”和“恢復(fù)頁(yè)眉頁(yè)腳”的超級(jí)鏈接,并調(diào)用自定義函數(shù)PageSetup_del()和PageSetup_set()實(shí)現(xiàn)相應(yīng)功能。代碼如下:

<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ="PageSetup_del()">清空頁(yè)眉頁(yè)腳</a>

<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ="PageSetup_set()"> 恢復(fù)頁(yè)眉頁(yè)腳 </a>

(4)建立相關(guān)的打印超級(jí)鏈接,并調(diào)用WebBrowser控件的相應(yīng)參數(shù)實(shí)現(xiàn)打印預(yù)覽、打印等功能。代碼如下:

<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ="document.all.WebBrowser.Execwb(7,1)">打印預(yù)覽</a>

 <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ="document.all.WebBrowser.Execwb(6,1)">打印</a>

 <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ="document.all.WebBrowser.Execwb(6,6)">直接打印</a>

 <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ="document.all.WebBrowser.Execwb(8,1)">頁(yè)面設(shè)置</a>

總結(jié)

以上所述是小編給大家介紹的JavaScript修改注冊(cè)表的方法,希望對(duì)大家有所幫助!

相關(guān)文章

最新評(píng)論