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

詳解JavaScript修改注冊表的方法

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

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

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

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

WshShell.RegWrite strName, anyValue, [strType]

參數(shù)說明

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

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

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

實現(xiàn)過程

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

< language=" "> 
 var HKEY_RootPath="HKEY_CURRENT_USER//Software//Microsoft//Internet Explorer//PageSetup//"; function PageSetup_del()
{  
 //清空頁眉頁腳
 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ù)頁眉頁腳 
 try{ 
 var WSc=new ActiveX ("W .Shell");  HKEY_Key="header"; 
 WSc.RegWrite(HKEY_RootPath+HKEY_Key,"&w&b頁碼,&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)建“清空頁眉頁腳”和“恢復(fù)頁眉頁腳”的超級鏈接,并調(diào)用自定義函數(shù)PageSetup_del()和PageSetup_set()實現(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()">清空頁眉頁腳</a>

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

(4)建立相關(guān)的打印超級鏈接,并調(diào)用WebBrowser控件的相應(yīng)參數(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)">頁面設(shè)置</a>

總結(jié)

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

相關(guān)文章

最新評論