Ejemplo n.º 1
0
        public WLAN_HOSTED_NETWORK_STATUS QueryStatus()
        {
            WLAN_HOSTED_NETWORK_STATUS status;

            WiFiUtils.Throw_On_Win32_Error(wlanapi.WlanHostedNetworkQueryStatus(this._WlanHandle, out status, IntPtr.Zero));
            return(status);
        }
Ejemplo n.º 2
0
        public WLAN_HOSTED_NETWORK_REASON InitSettings()
        {
            WLAN_HOSTED_NETWORK_REASON failReason;

            WiFiUtils.Throw_On_Win32_Error(wlanapi.WlanHostedNetworkInitSettings(this._WlanHandle, out failReason, IntPtr.Zero));
            return(failReason);
        }
Ejemplo n.º 3
0
        public WLAN_HOSTED_NETWORK_REASON SetSecondaryKey(string passKey)
        {
            WLAN_HOSTED_NETWORK_REASON failReason;

            WiFiUtils.Throw_On_Win32_Error(wlanapi.WlanHostedNetworkSetSecondaryKey(this._WlanHandle, (uint)(passKey.Length + 1), passKey, true, true, out failReason, IntPtr.Zero));

            return(failReason);
        }
Ejemplo n.º 4
0
        public WLAN_HOSTED_NETWORK_REASON QuerySecondaryKey(out string passKey, out bool isPassPhrase, out bool isPersistent)
        {
            WLAN_HOSTED_NETWORK_REASON failReason;
            uint keyLen;

            WiFiUtils.Throw_On_Win32_Error(wlanapi.WlanHostedNetworkQuerySecondaryKey(this._WlanHandle, out keyLen, out passKey, out isPassPhrase, out isPersistent, out failReason, IntPtr.Zero));
            return(failReason);
        }
Ejemplo n.º 5
0
        public WLAN_HOSTED_NETWORK_REASON ForceStart()
        {
            WLAN_HOSTED_NETWORK_REASON failReason;

            WiFiUtils.Throw_On_Win32_Error(wlanapi.WlanHostedNetworkForceStart(this._WlanHandle, out failReason, IntPtr.Zero));

            this._HostedNetworkState = WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active;

            return(failReason);
        }
Ejemplo n.º 6
0
        public void set(WLAN_HOSTED_NETWORK_OPCODE code, T Value, out WLAN_HOSTED_NETWORK_REASON failReason)
        {
            dataPtr = Marshal.AllocHGlobal(Marshal.SizeOf(Value));
            Marshal.StructureToPtr(Value, dataPtr, false);

            WiFiUtils.Throw_On_Win32_Error(
                wlanapi.WlanHostedNetworkSetProperty(
                    handle,
                    code,
                    (uint)Marshal.SizeOf(Value), dataPtr, out failReason, IntPtr.Zero
                    )
                );
        }
Ejemplo n.º 7
0
        public WLAN_HOSTED_NETWORK_REASON StopUsing()
        {
            if (this._HostedNetworkState != WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active)
            {
                this.onHostedNetworkAvailable();
                return(WLAN_HOSTED_NETWORK_REASON.wlan_hosted_network_reason_success);
            }
            WLAN_HOSTED_NETWORK_REASON failReason;

            WiFiUtils.Throw_On_Win32_Error(wlanapi.WlanHostedNetworkStopUsing(this._WlanHandle, out failReason, IntPtr.Zero));

            this._HostedNetworkState = WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_idle;

            return(failReason);
        }
Ejemplo n.º 8
0
        public T get(WLAN_HOSTED_NETWORK_OPCODE code, out WLAN_OPCODE_VALUE_TYPE opcode)
        {
            uint dataSize;

            WiFiUtils.Throw_On_Win32_Error(
                wlanapi.WlanHostedNetworkQueryProperty(
                    handle,
                    code,
                    out dataSize, out dataPtr, out opcode, IntPtr.Zero
                    )
                );

            var data = (T)Marshal.PtrToStructure(dataPtr, typeof(T));

            return(data);
        }
Ejemplo n.º 9
0
        public WLAN_HOSTED_NETWORK_REASON StartUsing()
        {
            if (this._HostedNetworkState == WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active)
            {
                //         this.onHostedNetworkStarted();
                return(WLAN_HOSTED_NETWORK_REASON.wlan_hosted_network_reason_success);
            }
            Trace.TraceInformation("WiFi AdHoc Starting");
            WLAN_HOSTED_NETWORK_REASON failReason;

            WiFiUtils.Throw_On_Win32_Error(wlanapi.WlanHostedNetworkStartUsing(this._WlanHandle, out failReason, IntPtr.Zero));

            this._HostedNetworkState = WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active;

            return(failReason);
        }
Ejemplo n.º 10
0
 private void Init()
 {
     try
     {
         WiFiUtils.Throw_On_Win32_Error(wlanapi.WlanOpenHandle(wlanapi.WLAN_CLIENT_VERSION_VISTA, IntPtr.Zero, out this._ServerVersion, ref this._WlanHandle));
         WLAN_NOTIFICATION_SOURCE notifSource;
         WiFiUtils.Throw_On_Win32_Error(wlanapi.WlanRegisterNotification(this._WlanHandle, WLAN_NOTIFICATION_SOURCE.All, true, this._notificationCallback, IntPtr.Zero, IntPtr.Zero, out notifSource));
         WLAN_HOSTED_NETWORK_REASON failReason = this.InitSettings();
         if (failReason != WLAN_HOSTED_NETWORK_REASON.wlan_hosted_network_reason_success)
         {
             Trace.TraceInformation("WiFi Init Error WlanHostedNetworkInitSettings: " + failReason.ToString());
             throw new Exception("Init Error WlanHostedNetworkInitSettings: " + failReason.ToString());
         }
     }
     catch
     {
         wlanapi.WlanCloseHandle(this._WlanHandle, IntPtr.Zero);
         Trace.TraceInformation("WiFi Init Error");
         throw;
     }
 }
Ejemplo n.º 11
0
        public WLAN_HOSTED_NETWORK_REASON ForceStop()
        {
            switch (this._HostedNetworkState)
            {
            case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active:
                Trace.TraceInformation("WiFi AdHoc Stopping");
                WLAN_HOSTED_NETWORK_REASON failReason;
                WiFiUtils.Throw_On_Win32_Error(wlanapi.WlanHostedNetworkForceStop(this._WlanHandle, out failReason, IntPtr.Zero));
                this._HostedNetworkState = WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_idle;
                return(failReason);

            case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_idle:
                //        this.onHostedNetworkAvailable();
                break;

            case WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_unavailable:
                //        this.onHostedNetworkUnavailable();
                break;
            }
            return(WLAN_HOSTED_NETWORK_REASON.wlan_hosted_network_reason_success);
        }