[C #] Winform tool-quick Wifi sharing under flash

Source: Internet
Author: User

[C #] Winform tool-quick Wifi sharing under flash

A. Introduction to tools

I have been busy changing my thesis recently. However, due to the lack of mobile phone traffic, I have been unable to bear the trouble of repeatedly Sharing Computer wifi, however, tools such as "Cheetah wifi" and "360wifi sharing" have caused the computer to sleep for many times (possibly due to the compatibility problem of the desktop USB Nic ). Therefore, I took the time to write a convenient tool, which was fully implemented using the built-in functions of windows. I combined several commands of "command prompt:

Set windows built-in wifi hotspots;

Enable and disable wifi;

Automatic shutdown and cancellation; (I like playing on the bed before going to bed, and I am too lazy to get up and shut down my computer)

And some. NET systems are managed:

Disable the flash messaging process (to avoid locking the sharing function );

Use windows libraries for automatic sharing to avoid manual configuration. (Many people may be stuck in this step)

Tested, this tool does not affect the heartbeat verification of the Flash message, and the Internet access is stable. It does not disconnect the network in a few minutes as it is shared manually.

Of course, if you are not a campus network user in the Zhejiang region, you may not need to dial for such information as flash messages. You just need to open a hotspot for sharing.

M [AVEDG @) 2 W %] ZD $ IJ4FQOO

B. Instructions and execution

Related command prompt (you can also use the BAT script)

Set the Virtual network Adapter Microsoft Virtual WiFi Miniport Adapter that comes with the system to create a hotspot (you only need to configure it before you use it for the first time ):

Netsh wlan set hostednetwork mode = allow ssid = Blz_Galaxy key = 1234567890

Here, the hotspot ID is Blz_Galaxy and the password is 1234567890. Please modify it by yourself.

Enable shared Wi-Fi hotspots:

Netsh wlan start hostednetwork

Disable Wifi hotspot:

Netsh wlan stop hostednetwork

Timed Shutdown (3600 seconds later ):

Shutdown-s-t 3600

You can also cancel the shutdown plan after setting shutdown:

Shutdown-

C # How to call console commands:

System. Diagnostics. Process _ pCmd;

_ PCmd = new System. Diagnostics. Process ();

_ PCmd. StartInfo. FileName = "cmd.exe ";

_ PCmd. StartInfo. UseShellExecute = false;

_ PCmd. StartInfo. RedirectStandardOutput = true;

_ PCmd. StartInfo. RedirectStandardInput = true;

_ PCmd. StartInfo. CreateNoWindow = true;

_ PCmd. Start ();

// Execute the target command

_ PCmd. StandardInput. WriteLine ("shutdown-");

Another example:

Regex reg = new Regex (@ "[\ u4e00-\ u9fa5]"); // Regular Expression

If (reg. IsMatch (textBox1.Text) | reg. IsMatch (textBox2.Text ))

{

MessageBox. Show ("cannot contain Chinese characters ");

Return;

}

If (textBox2.Text. Length

C. Perform system management through C # (. NET)

Automatically shut down the specified process (such as the "singleNet" Process of the flash)

Replaced manual search for processes in the task manager to save intensive phobias ~

Process [] processes = Process. GetProcessesByName (ProcessName );

Foreach (Process instance in processes)

{

Try

{

If (instance. ProcessName = ProcessName)

Instance. Kill ();;

}

Catch {}

By calling \ Windows \ system32 \ hnetcfg. dll, "NETCONLib" can be used for automatic sharing (key)

Try

{

String connectionToShare = this. textBox3.Text; // shared network connection

String sharedForConnection = this. textBox4.Text; // network connection to be shared

NetSharingManager manager = new NetSharingManager ();

Var connections = manager. EnumEveryConnection;

Foreach (INetConnection c in connections)

{

Var props = manager. NetConnectionProps [c];

Var sharingCfg = manager. INetSharingConfigurationForINetConnection [c];

If (props. Name = connectionToShare)

{

SharingCfg. EnableSharing (tagSHARINGCONNECTIONTYPE. ICSSHARINGTYPE_PUBLIC );

}

Else if (props. Name = sharedForConnection)

{

SharingCfg. EnableSharing (tagSHARINGCONNECTIONTYPE. ICSSHARINGTYPE_PRIVATE );

}

}

}

Catch

{

MessageBox. Show ("Open the network and sharing center. Check whether the Internet is connected! "," Prompt ", MessageBoxButtons. OK, MessageBoxIcon. Information );

}

Choose "Network Sharing Center"> "Change adapter Settings"> "singleNetPPPoE properties"> "share"> "allow internet sharing"> "select" sharing target ~

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.