zoukankan      html  css  js  c++  java
  • C#:通过Window API接口实现WiFi

    1、获取Mac地址

    //WiFi通知回调
            private WlanApi.WLAN_NOTIFICATION_CALLBACK _notificationCallback;
    
    this._notificationCallback = new WlanApi.WLAN_NOTIFICATION_CALLBACK(this.OnNotification);
                WLAN_NOTIFICATION_SOURCE notifSource;
                WiFiApiUtils.Throw_On_Win32_Error(WlanApi.WlanRegisterNotification(this._WlanHandle, WLAN_NOTIFICATION_SOURCE.All, true, this._notificationCallback, IntPtr.Zero, IntPtr.Zero, out notifSource));
    
    
            protected void OnNotification(ref WLAN_NOTIFICATION_DATA notifData, IntPtr context)
            {
                switch (notifData.notificationCode)
                {
                    case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_state_change:   //网络状态改变时
                        break;
                        
                    case (int)WLAN_HOSTED_NETWORK_NOTIFICATION_CODE.wlan_hosted_network_peer_state_change:  //客户端接入或退出WiFi时,记录或删除该客户端的mac地址等信息
    
                        if (notifData.dataSize > 0 && notifData.dataPtr != IntPtr.Zero)
                        {
                            WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE pPeerStateChange = (WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE)Marshal.PtrToStructure(notifData.dataPtr, typeof(WLAN_HOSTED_NETWORK_DATA_PEER_STATE_CHANGE));
    
                            if (pPeerStateChange.NewState.PeerAuthState == WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.wlan_hosted_network_peer_state_authenticated)
                            {
                                // Station joined the hosted network
                                this.onJoinWiFi(pPeerStateChange.NewState);
                            }
                            else if (pPeerStateChange.NewState.PeerAuthState == WLAN_HOSTED_NETWORK_PEER_AUTH_STATE.wlan_hosted_network_peer_state_invalid)
                            {
                                // Station left the hosted network
                                this.onLeaveWiFi(pPeerStateChange.NewState);
                            }
                            else
                            {
                                // Authentication state changed
                            }
                        }
    
                        break;
                }
    
    
            }
    View Code

    参考网址:


    https://msdn.microsoft.com/en-us/library/windows/desktop/ms706556%28v=vs.85%29.aspx
    https://msdn.microsoft.com/en-us/library/windows/desktop/dd439495(v=vs.85).aspx

    https://code.yhzm.me/shenchao/test_shen
    http://start.firefoxchina.cn/
    http://blog.csdn.net/lincyang/article/details/34430939
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms706556(v=vs.85).aspx
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms706749(v=vs.85).aspx
    https://msdn.microsoft.com/en-us/library/windows/desktop/aa816369(v=vs.85).aspx
    http://xjchilli.blog.163.com/blog/static/4534773920120161126917/
    http://managedwifi.codeplex.com/discussions/12073
    http://managedwifi.codeplex.com/
    http://www.codeproject.com/Articles/35329/How-to-access-wireless-network-parameters-using-na
    https://social.msdn.microsoft.com/search/en-us/windows?query=WiFi&Refinement=183
    http://cn.bing.com/search?q=c%23+wifi+api&FORM=QSRE2
    http://blog.csdn.net/hgy413/article/details/20784277
    http://stackoverflow.com/questions/25808620/c-sharp-connect-to-wifi-network-with-managed-wifi-api
    http://managedwifi.codeplex.com/SourceControl/changeset/view/41381#WlanApi.cs
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms706771(v=vs.85).aspx
    https://msdn.microsoft.com/en-us/library/windows/desktop/aa816369%28v=vs.85%29.aspx
    https://msdn.microsoft.com/en-us/library/ms706771(v=VS.85).aspx
    http://pietschsoft.com/archive#cat-C
    http://www.baidu.com/baidu?wd=WlanHostedNetworkForceStart&tn=monline_dg
    http://wenku.baidu.com/view/bee10913866fb84ae45c8d9c.html
    http://wenku.baidu.com/view/5317412ecf84b9d528ea7a70.html


    另附git参考:
    http://www.ruanyifeng.com/blog/2015/08/git-use-process.html
    http://www.ruanyifeng.com/blog/2012/07/git.html
    http://cn.bing.com/search?q=%2bgit+%e4%bd%bf%e7%94%a8+ruanyifeng&filters=rcrse%3a%221%22&FORM=RCRE
    http://www.cnblogs.com/GT_Andy/archive/2009/04/23/1922094.html
    http://jingyan.baidu.com/article/4b07be3c73400048b280f356.html

  • 相关阅读:
    解决 “invalid resource directory name”, resource “crunch”
    Unable to resolve target 'android-19'
    android SDK安装容易出错的原因
    Eclipse启动认定SDK地址,出现Error executing aapt
    解决Android SDK Manager更新下载速度慢
    Vue框架
    JSON
    Django之组件--cookie与session
    Django之组件--中间件
    Django之组件--forms
  • 原文地址:https://www.cnblogs.com/shenchao/p/4775104.html
Copyright © 2011-2022 走看看