[C #] Winform tool-quick Wifi sharing (Source Code) in the flash drive ),

Source: Internet
Author: User

[C #] Winform tool-quick Wifi sharing (Source Code) in the flash drive ),
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:

And some. NET systems are managed:

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.

Github source code (project file ):Https://github.com/Blz-Galaxy/Tools-Wifi-Sharing

 

B. Instructions and execution

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

  • Set the system's built-in Virtual network Adapter Microsoft Virtual WiFi Miniport AdapterCreate hotspot(You only need to configure before the first use ):
    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(Shutdown after 3600 seconds ):
    shutdown -s -t 3600
  • It can also be set after ShutdownCancel shutdown plan:
    shutdown -a

 

  • C # 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 <8) {MessageBox. show ("more than 8 passwords"); return;} _ strWrite = String. format ("netsh wlan set hostednetwork mode = allow ssid = {0} key = {1}", this. textBox1.Text, this. textBox2.Text); _ pCmd. standardInput. writeLine (_ strWrite );
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 { }

     

For details, see:[C #] specify that the process is disabled and Wifi sharing under flash

 

  • By calling \ Windows \ system32 \ hnetcfg. dll, "NETCONLib" can be used for automatic sharing.(Key)
    Try {string connectionToShare = this. textBox3.Text; // The shared network connection string sharedForConnection = this. textBox4.Text; // network connection to be shared NetSharingManager = 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 if the network is connected to the Internet! "," Prompt ", MessageBoxButtons. OK, MessageBoxIcon. Information );}

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

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.