最近要写个c#程序,已知SSID,密钥等,程序内部实现连接到指定的无线AP
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OpenNETCF;
using OpenNETCF.Net;
using OpenNETCF.Net.NetworkInformation;
namespace AcessPoint
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
WirelessZeroConfigNetworkInterface Wzc;
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
bool Astate = Wzc.ConnectToPreferredNetwork("4052");
listBox1.Items.Add("4052" + Astate.ToString());
}
private void button3_Click(object sender, EventArgs e)
{
bool Astate = Wzc.ConnectToPreferredNetwork("717");
listBox1.Items.Add("717" + Astate.ToString());
}
private void Form1_Load(object sender, EventArgs e)
{
INetworkInterface[] ArrWmc = WirelessZeroConfigNetworkInterface.GetAllNetworkInterfaces();
INetworkInterface Wmc = ArrWmc[0];
OpenNETCF.Net.NetworkInformation.EAPParameters Eap = new OpenNETCF.Net.NetworkInformation.EAPParameters();
Eap.Enable8021x = false;
Eap.AuthData = IntPtr.Zero;
Eap.AuthDataLen = 0;
Eap.EapType = EAPType.PEAP;
Eap.EapFlags = EAPFlags.Enabled;
Wzc = (WirelessZeroConfigNetworkInterface)Wmc;
Wzc.AddPreferredNetwork(
"4052", false, "0000000000", 1, OpenNETCF.Net.NetworkInformation.AuthenticationMode.Open, OpenNETCF.Net.NetworkInformation.WEPStatus.WEPEnabled, Eap);
Wzc.AddPreferredNetwork(
"717", false, "1234567890", 1, OpenNETCF.Net.NetworkInformation.AuthenticationMode.Open, OpenNETCF.Net.NetworkInformation.WEPStatus.WEPEnabled, Eap);
}
}
}
其他参考:
1. http://www.cnblogs.com/aga-j/archive/2010/08/09/1795375.html
2. http://www.cnblogs.com/aga-j/archive/2010/07/27/1786488.html
3. http://www.cnblogs.com/MobileBo/archive/2010/09/02/1816213.html
OpenNETCF 2.3 下载
http://www.opennetcf.com/LinkClick.aspx?fileticket=ZZBxc7fhnz4%3d&tabid=65&mid=959
本地下载: https://files.cnblogs.com/cyrix/SDF_Community.2.3.0.39.zip