자 바스 크 립 트 레 지 스 트 수정 방법

4595 단어 js레 지 스 트
이 인 스 턴 스 는 주로 WshShell 대상 의 관련 방법 을 통 해 이 루어 집 니 다.WshShell 대상 은 WSH(WSH 는 Windows ing Host 의 줄 임 말,Windows 운영 체제 에 내 장 된 스 크 립 트 언어 작업 환경)의 내장 대상 으로 프로그램의 로 컬 실행,레 지 스 트 처리,단축 키 만 들 기,시스템 폴 더 정보 획득 및 환경 변수 처리 등 을 주로 담당한다.WshShell 대상 의 관련 방법 은 표 11.1 과 같다.

이 인 스 턴 스 는 주로 RegWrite 방법 을 사용 하 였 으 며,다음은 이 방법 에 대해 상세 하 게 소개 할 것 입 니 다.
RegWrite 방법 은 레 지 스 트 에 지정 한 키 나 값 을 설정 하 는 데 사 용 됩 니 다.문법 형식 은 다음 과 같 습 니 다.WshShell.RegWrite strName, anyValue, [strType]매개 변수 설명
l     strName:레 지 스 트 의 키 나 값 을 지정 하 는 데 사 용 됩 니 다.strName 이 크로스 바(가운데/)로 끝나 면 이 방법 은 키 를 설정 합 니 다.그렇지 않 으 면 값 을 설정 합 니 다.strName 인 자 는 루트 키 로"HKEYCURRENT_USER”、 “HKEY_LOCAL_MACHINE”、“HKEY_CLASSES_ROOT”、“HKEY_USERS"또는"HKEYCURRENT_CONFIG 시작.
l     AnyValue:레 지 스 트 의 키 나 값 을 지정 하 는 데 사 용 됩 니 다.strType 이 REG 일 때SZ 또는 REGEXPAND_SZ 시 RegWrite 방법 은 anyValue 를 문자열 로 자동 으로 변환 합 니 다.strType 이 REG 이면DWORD 는 anyValue 를 정수 로 변환 합 니 다.strType 이 REG 이면BINARY,anyValue 는 정수 여야 합 니 다.
l     StrType:레 지 스 트 의 키 나 값 을 지정 하 는 데이터 형식 입 니 다.RegWrite 방법 이 지원 하 는 데이터 형식 은 REG 입 니 다.SZ、REG_EXPAND_SZ、 REG_DWORD 와 REGBINARY。다른 데이터 형식 은 strType 으로 전달 되 고 RegWrite 는 E 로 되 돌아 갑 니 다.INVALIDARG。
실현 과정
(1)사용자 정의 함수 작성 PageSetupdel()과 PageSetupset()는 머 릿 말 꼬리 를 비우 고 머 릿 말 꼬리 를 복원 하 는 기능 을 수행 합 니 다.구체 적 인 코드 는 다음 과 같다.

< 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()
{ 
 //       
 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 탭 을 만 들 고 웹 브 라 우 저 컨트롤 을 호출 합 니 다.코드 는 다음 과 같 습 니 다.

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

</ >
(3)"머 릿 말 삭제"와"머 릿 말 복구"의 하이퍼링크 를 만 들 고 사용자 정의 함수 PageSetup 호출del()과 PageSetupset()는 해당 기능 을 실현 합 니 다.코드 는 다음 과 같 습 니 다:

<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()">        </a>
(4)관련 인쇄 하이퍼링크 를 구축 하고 웹 브 라 우 저 컨트롤 의 해당 매개 변 수 를 호출 하여 인쇄 미리 보기,인쇄 등 기능 을 실현 합 니 다.코드 는 다음 과 같 습 니 다:

<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)">    </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)">    </a>
총결산
위 에서 말 한 것 은 소 편 이 소개 한 자바 스 크 립 트 가 레 지 스 트 를 수정 하 는 방법 입 니 다.여러분 에 게 도움 이 되 기 를 바 랍 니 다!

좋은 웹페이지 즐겨찾기