"C #" WinForm Tool-Quick share WiFi (source code) under Flash

Source: Internet
Author: User

A. Introduction to Tools

Recently busy to change papers, but due to mobile phone no traffic, repeated sharing of computer WiFi operation has let me unbearable, and "Cheetah WiFi" "360wifi sharing" and other tools have caused the computer to sleep many times (may be the desktop USB NIC compatibility problem). So I took the time to write a handy tool that took full advantage of the Windows self-feature implementation, which mainly incorporates several commands from the command prompt:

    1. Set up windows to bring WiFi hotspot;
    2. Turn wifi on and off;
    3. Auto Power off and cancel;(mainly I like to sleep in bed before playing on the cell phone, and do not bother to shut down the computer)

Well part. NET to manage the system:

    1. Turn off the flash process (avoid the flash lock sharing function);
    2. automate sharing with Windows-brought libraries to avoid manual setup. (Many people may be stuck in this step)

After testing, this tool does not affect the flash heartbeat verification, the internet is stable, and will not be like a manual sharing in a few minutes after the network will be broken.

Of course , if not the campus network in Zhejiang Province, users may not need to dial this type of flash, directly open the hotspot to share.

GitHub source program (project file) : https://github.com/Blz-Galaxy/Tools-Wifi-Sharing

B. Directives and enforcement

Related command prompt (can also be called with bat script)

    • Set up the system's own virtual NIC with Microsoft Virtual WiFi Miniport Adapter to create hotspots (just configure before first use):
      Set mode=allow ssid=blz_galaxy key=1234567890

Here the hotspot is identified as Blz_galaxy, the password is 1234567890, please modify it yourself.

    • to open a shared WiFi hotspot :
      Start hostednetwork
    • turn off WiFi hotspot :
      Netsh wlan stop hostednetwork
    • Timer shutdown (shutdown after 3,600 seconds):
      Shutdown-s-T 3600
    • The shutdown plan can also be canceled after setting the shutdown:
      Shutdown-a

  • C # Calling console directives mode
    System.Diagnostics.Process _pcmd;_pcmd=NewSystem.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 target Directive_pcmd.standardinput.writeline ("shutdown-a");

One more example:

  • Regex reg =NewRegex (@"[\u4e00-\u9fa5]");//Regular Expressionsif(Reg. IsMatch (TextBox1.Text) | |Reg. IsMatch (TextBox2.Text)) {MessageBox.Show ("cannot contain Chinese characters"); return;}if(TextBox2.Text.Length <8) {MessageBox.Show ("password more than 8 digits"); 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. System Management through C # (. NET)
    • Automatically closes the specified process (such as the "singlenet" process of the Flash)

instead of manually finding a process in Task manager, rescuing people with severe phobias ~

    • Process[] processes = process.getprocessesbyname (ProcessName); foreach inch processes) {    try    {        if (instance. ProcessName = = ProcessName)            instance. Kill ();;    }     Catch { }

For details, refer to: "C #" specifies the process shutdown & WiFi sharing under the Flash

  • call \windows\system32\hnetcfg.dll, which enables automatic sharing with "netconlib" (Key)
    Try{    stringConnectiontoshare = This. TextBox3.Text;//network connections that are shared    stringSharedforconnection = This. Textbox4.text;//Network connections that need to be sharedNetsharingmanager Manager=NewNetsharingmanager (); varConnections =Manager.    Enumeveryconnection; foreach(Inetconnection Cinchconnections) {        varProps =Manager.netconnectionprops[c]; varSharingcfg =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 ("please open network and Sharing Center • See if you are connected internet! ","Tips", MessageBoxButtons.OK, messageboxicon.information);}

Replace manual access to "Network Sharing Center, change adapter settings->singlenetpppoe properties, share," Check allow sharing internet-> Select Share Target "This series of actions, lazy Gospel ~

"C #" WinForm Tool-Quick share WiFi (source code) under Flash

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.