Home>

This example is mainly implemented through related methods of the wshshell object.The wshshell object is a built-in object of wsh (wsh is the abbreviation of windows ing host, a scripting language working environment embedded in the windows operating system),It is mainly responsible for the local operation of the program, processing the registry, creating shortcuts, obtaining system folder information, and processing environment variables. The related methods of the wshshell object are shown in Table 11.1.

This example mainly uses the regwrite method, which will be described in detail below.

The regwrite method is used to set the specified key or value in the registry.Its syntax is as follows:

wshshell.regwrite strname, anyvalue, [strtype]

Parameter Description

l strname:the key or value used to specify the registry,If strname ends with a backslash (//in), this method sets the key,Otherwise set the value.The strname parameter must begin with the root key name "hkey_current_user", "hkey_local_machine", "hkey_classes_root", "hkey_users", or "hkey_current_config".

l anyvalue:a value used to specify a key or value of the registry.When strtype is reg_sz or reg_expand_sz, the regwrite method automatically converts anyvalue to a string.If strtype is reg_dword, anyvalue is converted to an integer.If strtype is reg_binary, anyvalue must be an integer.

l strtype:used to specify the data type of the key or value of the registry.The data types supported by the regwrite method are reg_sz, reg_expand_sz, reg_dword, and reg_binary. The other data types are passed as strtype, and regwrite returns e_invalidarg.

Implementation process

(1) Write custom functions pagesetup_del () and pagesetup_set () to implement the functions of clearing the header and footer and restoring the header and footer.The specific code is as follows:

<language="">
 var hkey_rootpath="hkey_current_user //software //microsoft //internet explorer //pagesetup //";function pagesetup_del ()
{
 //Empty header and footer
 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 ()
{
 //Resume header and footer
 try {
 var wsc=new activex ("w .shell");hkey_key="header";
 wsc.regwrite (hkey_rootpath + hkey_key, "&w&b page number,&p /&p");
hkey_key="footer";
 wsc.regwrite (hkey_rootpath + hkey_key, "&u&b&d");
 } catch (e) {}
}
</>

(2) Create a html tag and call the webbrowser control. The code is as follows:

<classid="clsid:8856f961-340a-11d0-a96b-00c04fd705a2" width="0" height="0"&​​gt;
</>

(3) Create hyperlinks to "Empty header and footer" and "Restore header and footer"And call the custom functions pagesetup_del () and pagesetup_set () to achieve the corresponding functions.code show as below:

<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow"="pagesetup_del ()">Empty header&footer</a>
<a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow"="pagesetup_set ()">Restore header&footer</a>

(4) Establish related print hyperlinks,And call the corresponding parameters of the webbrowser control to achieve print preview, print and other functions.code show as below:

<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) ">Print Preview</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) ">print</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) ">print directly</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) ">page setup</a>

to sum up

  • Previous Summary of several parameter initialization methods on tensorflow
  • Next Detailed use of prop () in jQuery
  • Trends