C # disable local connection and modify Internet Explorer Settings

Source: Internet
Author: User

I haven't written a blog for many days. Due to the recent changes in the company's network, I had to pay for the Internet and get dizzy. All I had to do was find the network card to access the Internet. However, when I used wireless, I couldn't go to the LAN.

Switching back and forth to the network and changing the proxy settings is a little troublesome. All of them have written a small software, which is convenient for you.

This software has two main functions: 1. enable or disable the NIC and set it based on the name. 2. Modify the Registry to change the IE settings.

Two paragraphsCodeCome up

1. Enable disable Nic. This is found online.

/// <Summary>
/// Enable or disable Local Network Connections
/// </Summary>
/// <Param name = "networkname"> Local Connection name </Param>
/// <Param name = "operation"> Operation, input "enable" or "Disable" </Param>
Static Bool Network ( String Networkname, String Operation)
{
Bool Result = False ;
Shell32.shell Shell = New Shell32.shellclass ();
Shell32.folder folder = Shell. namespace ( 49 );
Foreach (Shell32.folderitem fi In Folder. Items ())
{
If (Fi. Name ! = Networkname)
Continue ;
Shell32.shellfolderitem folderitem = (Shell32.shellfolderitem) Fi;
Foreach (Shell32.folderitemverb fiv In Folderitem. verbs ())
{
If ( ! FIV. Name. Contains (operation ))
{
Continue ;
}
Else
{
Result = True ;
FIV. doit ();
Thread. Sleep ( 1000 );
Break ;
}
}
}
Return Result;
}

2. Modify the registry and change the iesettings.

// Open Registry Key
Microsoft. win32.registrykey rk = Microsoft. win32.registry. currentuser. opensubkey ( @" SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Internet Settings " , True );

//Set automatic script address
Rk. setvalue ("Autoconfigurl","");

Txtmessage. Text+ ="The IE automatic script is successfully configured!"+"\ R \ n";

// set proxy availability
rk. setvalue ( " proxyenable " , 0 );
// set proxy IP address and port
rk. setvalue ( " proxyserver " , configurationmanager. connectionstrings [ " proxyserver " ]. connectionstring);

Txtmessage. Text+ ="The IE proxy server is configured successfully!"+"\ R \ n";
Rk. Close ();

This is simple for your convenience.

Some settings can be configured in the config file.

Source code

 

From: http://www.cnblogs.com/stalwart/archive/2011/09/20/2182663.html

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.