Asp.net modify the Registry (when the page is printed, the header, footer, margin, background color and image)

Source: Internet
Author: User
Using  System;  Using  System. Collections. Generic;  Using  System. Web;  Using  System. Web. UI;  Using  System. Web. UI. webcontrols;  Using  Microsoft. Win32;  Public   Partial   Class Printsetdefault: system. Web. UI. Page {  Protected   Void Page_load ( Object  Sender, eventargs e ){  If (Readreg () = 1  ){  If (Writereg () = 1  ) {Readreg (); response. Write (  "  Game over! "  );}}}  ///   <Summary>      ///  Read Registry  ///   </Summary>      ///   <Returns> </returns>      Protected   Int  Readreg (){  //  Read Registry Registrykey regread;  //  Read the subkeys in the HKEY_CURRENT_USER primary key. Regread = registry. currentuser. opensubkey ( "  Software \ Microsoft \ Internet Explorer \ pagesetup  " , True  );  If (Regread = Null ) //  If this subkey does not exist  {Response. Write ( "  Pagesetup: NULL </BR>  "  );  Return   0  ;}  Else  {Response. Write (  "  Pagesetup: OK </BR>  "  );  Object OBJ = regread. getvalue ( " Header  " ) = Null ? "  Null  " : Regread. getvalue ( "  Header  " ); //  Read Value Response. Write ( "  Header:  " + Obj. tostring () + " </BR>  "  ); OBJ = Regread. getvalue ( "  Footer  " ) = Null ? "  Null  " : Regread. getvalue ( "  Footer  " ); //  Read Value Response. Write ("  Footer:  " + Obj. tostring () + "  </BR>  "  ); OBJ = Regread. getvalue ( "  Margin_left  " ) = Null ? "  Null  " : Regread. getvalue ( " Margin_left  " ); //  Read Value Response. Write ( "  Margin_left:  " + Obj. tostring () + "  </BR>  "  ); OBJ = Regread. getvalue ( "  Margin_right  " ) = Null ? "  Null  " : Regread. getvalue ( "  Margin_right  " ); //  Read Value Response. Write ( "  Margin_right:  " + Obj. tostring () + "  </BR>  "  ); OBJ = Regread. getvalue ( "  Margin_top  " ) = Null ? "  Null  " : Regread. getvalue ( "  Margin_top  " ); //  Read Value Response. Write ( "  Margin_top:  " + Obj. tostring () + "  </BR>  "  ); OBJ = Regread. getvalue ( "  Margin_bottom  " ) = Null ? "  Null  " : Regread. getvalue ( "  Margin_bottom  " ); // Read Value Response. Write ( "  Margin_bottom:  " + Obj. tostring () + "  </BR>  "  ); OBJ = Regread. getvalue ( "  Print_background  " ) = Null ? "  Null  " : Regread. getvalue ( "  Print_background  " ); //  Read Value Response. Write ( "  Print_background:  " + Obj. tostring () + "  </BR>  "  ); Response. Write (  "  </BR>  " );} Regread. Close ();  Return   1  ;}  ///   <Summary>      ///  Write registry  ///   </Summary>      Protected   Int  Writereg (){  //  Write registry Registrykey regwrite;  //  Write subkeys to the primary key of HKEY_CURRENT_USER  //  If the sub-key already exists, the system will automatically overwrite it. Regwrite = registry. currentuser. createsubkey ( "  Software \ Microsoft \ Internet Explorer \ pagesetup  "  );  //  Add data items to the test subkey Regwrite. setvalue ( "  Header  " , "  & W & bpage & P of & P  "  ); Regwrite. setvalue (  "  Footer  " , "  & U & B & D  "  ); Regwrite. setvalue (  "  Margin_left  " , 0.750000 ); Regwrite. setvalue (  "  Margin_right  " , 0.750000  ); Regwrite. setvalue (  "  Margin_top  " , 0.750000  ); Regwrite. setvalue (  "  Margin_bottom  " , 0.750000 ); Regwrite. setvalue (  "  Print_background  " , "  No  "  );  //  Close this object  Regwrite. Close ();  Return   1  ;}} 

The above result is restored to the default value. You can also change it to 0.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.