• 大小: 89KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-05-27
  • 语言: C#
  • 标签: Native  Wifi  wlanapi  

资源简介

Native Wifi C#示例,wlanapi使用实例

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.xml;

namespace NativeWifi
{
    public partial class Form1 : Form
    {
        Wlan wal = new Wlan();
        WlanClient wlanClient = new WlanClient();
        IntPtr opintptr1;
        IntPtr opintptr2;
        IntPtr opintptr3;
        IntPtr getprofilexml;
        Wlan.WlanProfileFlags wflas;
        Wlan.WlanAccess er;

        Wlan.Dot11Ssid ssid;
        public Form1()
        {
            InitializeComponent();
        }
        static string GetStringForSSID(Wlan.Dot11Ssid ssid)
        {
            return Encoding.UTF8.GetString(ssid.SSID 0 (int)ssid.SSIDLength);
        }
        private void button1_Click(object sender EventArgs e)
        {
            IntPtr opintptr;
            
            UInt32 negotiatedVersion;
            WlanClient.WlanInterface[] wlaninter = new WlanClient.WlanInterface[5];
            wlaninter = wlanClient.Interfaces;
            //this.textBox1.AppendText(wlaninter[0].InterfaceName + “ “ + wlaninter[0].InterfaceDescription + “ “ + wlaninter[0].InterfaceGuid+“\r\n“);
            
            Wlan.WlanOpenHandle(1 opintptr1 out negotiatedVersion out opintptr);
            this.textBox1.AppendText(negotiatedVersion.ToString() + “ “ + opintptr.ToString() + “\r\n“);
            Wlan.WlanScan(opintptr wlaninter[0].InterfaceGuid IntPtr.Zero IntPtr.Zeroopintptr3);
            int a=Wlan.WlanGetAvailableNetworkList(opintptr wlaninter[0].InterfaceGuid Wlan.WlanGetAvailableNetworkFlags.IncludeAllAdhocProfiles opintptr1 out opintptr3);
            Wlan.WlanAvailableNetworkListHeader availNetListHeader = (Wlan.WlanAvailableNetworkListHeader)Marshal.PtrToStructure(opintptr3 typeof(Wlan.WlanAvailableNetworkListHeader));
            long availNetListIt = opintptr3.ToInt64() + Marshal.SizeOf(typeof(Wlan.WlanAvailableNetworkListHeader));
            Wlan.WlanAvailableNetwork[] availNets = new Wlan.WlanAvailableNetwork[availNetListHeader.numberOfItems];
            for (int i = 0; i < availNetListHeader.numberOfItems; ++i)
            {
                availNets[i] = (Wlan.WlanAvailableNetwork)Marshal.PtrToStructure(new IntPtr(availNetListIt) typeof(Wlan.WlanAvailableNetwork));
                availNetListIt += Marshal.SizeOf(typeof(Wlan.WlanAvailableNetwork));
            }
            
            foreach (Wlan.WlanAvailableNetwork network in availNets)
            {

                string sid = GetStringForSSID(network.dot11Ssid);

                if (network.flags.ToString() == “Connected HasProfile“)
                {
                    this.textBox1.AppendText(“\r\n“ + sid + “ “ + network.dot11DefaultCipherAlgorithm.ToString() + “ “ + network.flags.ToString() + “\r\n“);
                    Wlan.WlanGet

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      35840  2012-10-12 16:13  NativeWifi\bin\Debug\NativeWifi.exe

     文件      56832  2012-10-12 16:13  NativeWifi\bin\Debug\NativeWifi.pdb

     文件      14328  2013-03-26 16:18  NativeWifi\bin\Debug\NativeWifi.vshost.exe

     文件        490  2007-07-21 01:33  NativeWifi\bin\Debug\NativeWifi.vshost.exe.manifest

     文件       7643  2012-10-12 16:08  NativeWifi\Form1.cs

     文件       3815  2012-10-12 10:42  NativeWifi\Form1.Designer.cs

     文件       5814  2012-10-12 10:42  NativeWifi\Form1.resx

     文件      60053  2012-10-12 10:08  NativeWifi\Interop.cs

     文件       3807  2012-10-12 07:57  NativeWifi\NativeWifi.csproj

     文件        817  2013-03-26 16:18  NativeWifi\obj\Debug\NativeWifi.csproj.FileListAbsolute.txt

     文件        847  2012-10-12 10:51  NativeWifi\obj\Debug\NativeWifi.csproj.GenerateResource.Cache

     文件      35840  2012-10-12 16:13  NativeWifi\obj\Debug\NativeWifi.exe

     文件        180  2012-10-12 10:51  NativeWifi\obj\Debug\NativeWifi.Form1.resources

     文件      56832  2012-10-12 16:13  NativeWifi\obj\Debug\NativeWifi.pdb

     文件        180  2012-10-12 08:01  NativeWifi\obj\Debug\NativeWifi.Properties.Resources.resources

     文件        491  2012-10-12 07:55  NativeWifi\Program.cs

     文件       1376  2012-10-12 07:55  NativeWifi\Properties\AssemblyInfo.cs

     文件       2870  2012-10-12 07:55  NativeWifi\Properties\Resources.Designer.cs

     文件       5612  2012-10-12 07:55  NativeWifi\Properties\Resources.resx

     文件       1095  2012-10-12 07:55  NativeWifi\Properties\Settings.Designer.cs

     文件        249  2012-10-12 07:55  NativeWifi\Properties\Settings.settings

     文件      29211  2012-10-12 16:13  NativeWifi\WlanApi.cs

     文件        920  2012-10-12 07:55  NativeWifi.sln

     目录          0  2012-10-12 07:55  NativeWifi\obj\Debug\TempPE

     目录          0  2012-10-12 08:02  NativeWifi\bin\Debug

     目录          0  2012-10-12 16:08  NativeWifi\obj\Debug

     目录          0  2012-10-12 07:55  NativeWifi\bin

     目录          0  2012-10-12 07:55  NativeWifi\obj

     目录          0  2012-10-12 07:55  NativeWifi\Properties

     目录          0  2012-10-12 16:13  NativeWifi

............此处省略3个文件信息

评论

共有 条评论