Click here to Skip to main content
15,919,358 members

Comments by chd_diamond (Top 3 by date)

chd_diamond 7-Sep-15 7:05am View    
private void button1_Click(object sender, EventArgs e)
{

// lstNetworks.Items.Clear();



WlanClient client = new WlanClient();

foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)

{

Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList(0);

foreach (Wlan.WlanAvailableNetwork network in networks)

{

Wlan.Dot11Ssid ssid = network.dot11Ssid;

string networkName = Encoding.ASCII.GetString(ssid.SSID, 0, (int)ssid.SSIDLength);



ListViewItem item = new ListViewItem(networkName);

item.SubItems.Add(network.dot11DefaultCipherAlgorithm.ToString());

item.SubItems.Add(network.wlanSignalQuality + "%");

// lstNetworks.Items.Add(item);

}

}
}

// I get error at this point WlanClient client = new WlanClient();

error is: An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in ManagedWifi.dll

Additional information: The service has not been started

It further move to function

public WlanClient()
{
Wlan.ThrowIfError(
Wlan.WlanOpenHandle(Wlan.WLAN_CLIENT_VERSION_XP_SP2, IntPtr.Zero, out negotiatedVersion, out clientHandle));
try
{
Wlan.WlanNotificationSource prevSrc;
wlanNotificationCallback = new Wlan.WlanNotificationCallbackDelegate(OnWlanNotification);
Wlan.ThrowIfError(
Wlan.WlanRegisterNotification(clientHandle, Wlan.WlanNotificationSource.All, false, wlanNotificationCallback, IntPtr.Zero, IntPtr.Zero, out prevSrc));
}
catch
{
Wlan.WlanCloseHandle(clientHandle, IntPtr.Zero);
throw;
}
}
chd_diamond 7-Sep-15 6:59am View    
Thanks for providing the link. I tried the same code but get an error :
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in ManagedWifi.dll

Additional information: The service has not been started

Any solution?
chd_diamond 7-Sep-15 6:58am View    
I tried code but get exception :
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in ManagedWifi.dll

Additional information: The service has not been started