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.