コード例 #1
0
        private void remoteAutoStart()
        {
            debugBox.AppendText("**************\r\n自动启动即将生效\r\n***********************");
            RegistryKey registerAutoStart = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            registerAutoStart.DeleteValue("HuFamilyWifi");

            debugBox.AppendText(Environment.NewLine + HostedNetwork.SetHostedNetwork(ssidTextbox.Text, passwdTextbox.Text));
            debugBox.AppendText(Environment.NewLine + HostedNetwork.SetStatus(enableCheckbox.Checked));
        }
コード例 #2
0
 private void readButton_Click(object sender, EventArgs e)
 {
     string[] result = HostedNetwork.GetHostedWirelessStatus();
     wirelessStatusLabel.Text = result[0] + ", " + result[5];
     ssidLabel.Text           = result[1];
     bssidLabel.Text          = result[6];
     encryptLabel.Text        = result[3];
     wirelessTypeLabel.Text   = result[7];
     channelLabel.Text        = result[8];
 }
コード例 #3
0
        private void addAutoStart()
        {
            debugBox.AppendText("**************\r\n自动启动即将生效,5秒后将应用相关设置\r\n**************");
            Thread.Sleep(5000);
            RegistryKey registerAutoStart = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            registerAutoStart.SetValue("HuFamilyWifi", Application.ExecutablePath);

            debugBox.AppendText(Environment.NewLine + HostedNetwork.SetHostedNetwork(ssidTextbox.Text, passwdTextbox.Text));
            debugBox.AppendText(Environment.NewLine + HostedNetwork.SetStatus(enableCheckbox.Checked));
        }
コード例 #4
0
 private void setButton_Click(object sender, EventArgs e)
 {
     if (ssidTextbox.Text != "")
     {
         debugBox.AppendText(Environment.NewLine + HostedNetwork.SetHostedNetwork(ssidTextbox.Text, passwdTextbox.Text));
         debugBox.AppendText(Environment.NewLine + HostedNetwork.SetStatus(enableCheckbox.Checked));
         LocalSetting.WriteSetting(ssidTextbox.Text, passwdTextbox.Text, enableCheckbox.Checked, autoStartCheckbox.Checked);
         MessageBox.Show("设置信息已写入,请检查右边的调试信息是否正确!", "设置成功", MessageBoxButtons.OK);
     }
     else
     {
         MessageBox.Show("SSID填写不正确,可能是未填写或存在非法字符!", "SSID错误", MessageBoxButtons.OK);
     }
 }
コード例 #5
0
        internal void OnWlanNotification(ref WlanNotificationData data, IntPtr context)
        {
            WlanInterface wlanIface = null;
            WlanEventArgs wlanEvent = WlanEventArgs.Empty;

            if (interfaceMap.ContainsKey(data.InterfaceGuid))
            {
                wlanIface = interfaceMap[data.InterfaceGuid];
                wlanEvent.InterfaceGuid = wlanIface.Guid;
            }
            wlanEvent.NotificationSource = data.NotificationSource;
            wlanEvent.NotificationCode   = data.NotificationCode;

            switch (data.NotificationSource)
            {
            case WlanNotificationSource.Acm:
                switch ((WlanAcmNotificationCode)data.NotificationCode)
                {
                case WlanAcmNotificationCode.ConnectionStart:
                case WlanAcmNotificationCode.ConnectionAttemptFail:
                case WlanAcmNotificationCode.Disconnecting:
                case WlanAcmNotificationCode.Disconnected:
                    break;

                case WlanAcmNotificationCode.ConnectionComplete:
                    WlanConnectionNotificationData?conNotif = ParseWlanConnectionNotificationData(ref data);
                    if (conNotif.HasValue && wlanIface != null)
                    {
                        AcmConnectionEventArgs conArgs = new AcmConnectionEventArgs();
                        conArgs.ConnectionData   = conNotif.Value;
                        conArgs.NotificationCode = WlanAcmNotificationCode.ConnectionComplete;
                        wlanIface.OnAcmConnectionCompleted(conArgs);
                    }
                    break;

                case WlanAcmNotificationCode.ScanFail:
                    //TODO parse WLAN_REASON_CODE in field Data
                    break;

                case WlanAcmNotificationCode.BssTypeChange:
                    //TODO parse DOT11_BSS_TYPE in field Data
                    break;

                case WlanAcmNotificationCode.PowerSettingChange:
                    //TODO parse WLAN_POWER_SETTING in field Data
                    break;

                case WlanAcmNotificationCode.ProfileNameChange:
                    //TODO parse two null-terminated WCHAR strings in field Data
                    break;

                case WlanAcmNotificationCode.AdhocNetworkStateChange:
                    //TODO parse WLAN_ADHOC_NETWORK_STATE in field Data
                    break;

                case WlanAcmNotificationCode.ScreenPowerChange:
                    //TODO parse BOOL in field Data
                    break;
                }
                OnAcmNotification(new AcmEventArgs());
                break;

            case WlanNotificationSource.Msm:
                switch ((WlanMsmNotificationCode)data.NotificationCode)
                {
                case WlanMsmNotificationCode.Associating:
                case WlanMsmNotificationCode.Associated:
                case WlanMsmNotificationCode.Authenticating:
                case WlanMsmNotificationCode.Connected:
                case WlanMsmNotificationCode.RoamingStart:
                case WlanMsmNotificationCode.RoamingEnd:
                case WlanMsmNotificationCode.Disassociating:
                case WlanMsmNotificationCode.Disconnected:
                case WlanMsmNotificationCode.PeerJoin:
                case WlanMsmNotificationCode.PeerLeave:
                case WlanMsmNotificationCode.AdapterRemoval:
                    //TODO parse WLAN_MSM_NOTIFICATION_DATA in field Data
                    break;

                case WlanMsmNotificationCode.AdapterOperationModeChange:
                    //TODO parse ULONG in field Data
                    break;

                case WlanMsmNotificationCode.SignalQualityChange:
                    //TODO parse ULONG for WLAN_SIGNAL_QUALITY in field Data
                    break;

                case WlanMsmNotificationCode.RadioStateChange: {
                    WlanPhyRadioState            radioState = Util.ParseStruct <WlanPhyRadioState>(data.Data, data.DataSize);
                    MsmRadioStateChangeEventArgs eventArgs  = new MsmRadioStateChangeEventArgs();
                    eventArgs.RadioState = radioState;
                    wlanIface.OnMsmRadioStateChange(eventArgs);
                }
                break;
                }
                OnMsmNotification(new MsmEventArgs());
                break;

            case WlanNotificationSource.OneX:
                OnOneXNotification(new OneXEventArgs());
                break;     //TODO

            case WlanNotificationSource.Security:
                OnSecurityNotification(new SecurityEventArgs());
                break;     //TODO

            case WlanNotificationSource.Ihv: {
                IhvEventArgs eventArgs = new IhvEventArgs();
                eventArgs.Data     = data.Data;
                eventArgs.DataSize = data.DataSize;
                OnIhvNotification(eventArgs);
            }
            break;         //TODO

            case WlanNotificationSource.HostedNetwork:
                if (HostedNetwork != null)
                {
                    switch ((WlanHostedNetworkNotificationCode)data.NotificationCode)
                    {
                    case WlanHostedNetworkNotificationCode.PeerStateChange: {
                        WlanHostedNetworkDataPeerStateChange peerStateChange = Util.ParseStruct <WlanHostedNetworkDataPeerStateChange>(data.Data, data.DataSize);
                        HnwkPeerStateChangeEventArgs         eventArgs       = new HnwkPeerStateChangeEventArgs();
                        eventArgs.PeerState = peerStateChange;
                        HostedNetwork.OnHnwkPeerStateChange(eventArgs);
                    }
                    break;

                    case WlanHostedNetworkNotificationCode.RadioStateChange: {
                        WlanHostedNetworkRadioState   radioState = Util.ParseStruct <WlanHostedNetworkRadioState>(data.Data, data.DataSize);
                        HnwkRadioStateChangeEventArgs eventArgs  = new HnwkRadioStateChangeEventArgs();
                        eventArgs.RadioState = radioState;
                        HostedNetwork.OnHnwkRadioStateChange(eventArgs);
                    }
                    break;

                    case WlanHostedNetworkNotificationCode.StateChange: {
                        WlanHostedNetworkStateChange stateChange = Util.ParseStruct <WlanHostedNetworkStateChange>(data.Data, data.DataSize);
                        HnwkStateChangeEventArgs     eventArgs   = new HnwkStateChangeEventArgs();
                        eventArgs.State = stateChange;
                        HostedNetwork.OnHnwkStateChange(eventArgs);
                    }
                    break;
                    }
                    wlanEvent.InterfaceGuid = HostedNetwork.Guid;
                    OnHwnkNotification(new HnwkEventArgs());
                }
                break;
            }
            OnWlanNotification(wlanEvent);
        }