הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Friday, December 4, 2015 4:55 PM
I am using VB Express 2010 on a PC running Windows 10.
I move around the country and connect to various wi-fi services. Is there a way to programatically acquire the name (not the address) of the wi-fi service to which I am connected?
All replies (11)
Sunday, December 6, 2015 10:18 PM ✅Answered
Sorry, I had assumed based on the type of question that your knowledge of the .NET Framework was more extensive.
You can easily call a C# class by adding a reference to the compiled C# DLL. After you have created your solution, add an "Existing project" and load the ManagedWifi.csproj file. Now compile to create the C# dll.
Now in your own project, right click on "Reference" category of the the project name and "Add Reference...". Click on Projects" and select "ManagedWifi".
Your own code should look something like:
Imports System.Text
Imports NativeWifi
Module Module1
Function GetSSID(ssid As Wlan.Dot11Ssid) As String
Return Encoding.ASCII.GetString(ssid.SSID, 0, ssid.SSIDLength)
End Function
Sub Main()
Dim client As New WlanClient
Dim ssids As New List(Of String)
For Each wlanIface As WlanClient.WlanInterface In client.Interfaces
Dim networks() As Wlan.WlanAvailableNetwork
networks = wlanIface.GetAvailableNetworkList(0)
For Each network In networks
ssids.Add(GetSSID(network.dot11Ssid))
Next
Next
End Sub
End Module
Sunday, December 13, 2015 6:29 PM ✅Answered
I found a solution - fairly simple:
Imports System.Net
Imports System.Text
Imports NativeWifi
dim wifi_connection as string
wifi_connection = get_connected_WIFI_SSID()
Public Function get_connected_WIFI_SSID() As String
Dim connected_ssid As Wlan.Dot11Ssid
Dim encoded_ssid As String = ""
Dim result As String = ""
Dim WlanClient = New WlanClient()
Try
For Each wlanInterface As WlanClient.WlanInterface In WlanClient.Interfaces
connected_ssid = wlanInterface.CurrentConnection.wlanAssociationAttributes.dot11Ssid
encoded_ssid = GetSSID(connected_ssid)
Exit For
Next
Catch ex As Exception
Return ("Error")
End Try
Return encoded_ssid
End Function
Public Function GetSSID(ssid As Wlan.Dot11Ssid) As String
Return Encoding.ASCII.GetString(ssid.SSID, 0, ssid.SSIDLength)
End Function
Ron Chandler
Saturday, December 5, 2015 8:45 PM
What I really want is the SSID of the network connection. I see another MSDN post stating that it is impossible to get the SSID! I can see it the SSID using control panel->network & sharing center->view network connections, so it must not be truly impossible to find! Please respond!
Ron Chandler
Sunday, December 6, 2015 12:20 AM
What I really want is the SSID of the network connection. I see another MSDN post stating that it is impossible to get the SSID! I can see it the SSID using control panel->network & sharing center->view network connections, so it must not be truly impossible to find! Please respond!
Ron Chandler
You can get at the SSID by using the Managed Wifi API posted on CodePlex.com.
Then code something like:
WlanClient client = new WlanClient();
List<string> ssids = new List<string> ();
foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
{
Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList (0);
foreach (var network in networks)
{
ssids.Add (GetSSID (network.dot11Ssid));
}
}
static string GetSSID (Wlan.Dot11Ssid ssid)
{
return Encoding.ASCII.GetString (ssid.SSID, 0, (int) ssid.SSIDLength);
}
I'll leave it to you to translate from C# to VB.NET. Also bear in mind I haven't tested the above code.
Sunday, December 6, 2015 1:12 PM
Thanks for the response. I downloaded the zipped files from managedwifi.zip and extracted them. They are all C#. I am coding in vb (didn't see a vb version there). I also do not quite know (or have forgotten) what to do with the extracted code. Should I add it to my project as a class module or a module? Please respond.
Thanks again
Ron Chandler
Sunday, December 6, 2015 8:19 PM
More clarification:
The statement;
Dim myClient As WlanClient
is a compile error - Type 'WlanClient' is not defined
I obviously need a reference, an import, an incude, or what?
Please respond.
Ron Chandler
Monday, December 7, 2015 2:33 PM
Thanks, but not there yet. I added "existing Item", ManagedWifi.csproj to my project (it's a vb project) and built the solution. It runs. ManagedWifi.csproj appears as part of my project but when I try to add the reference (referenc manager->solution->projects) nothing appears. Search on NativeWifi shows nothing. Where did it go?
I must be missing something simple. It looks like the ManagedWifi.csproj didn't build.
Please respond.
Ron Chandler
Monday, December 7, 2015 9:08 PM
Brian:
Please ignore my last reply. I mis-interpreted the instructions - I used "existing item" instead of file->add->existing project.
Ron Chandler
Tuesday, December 8, 2015 1:56 AM
I see the SSIDs now, but is there a way to tell which one I am connected to?
Ron Chandler
Wednesday, December 9, 2015 12:05 AM
Again, is there a way to tell which Internet service that I am conneced to?
Possible?
Ron Chandler
Wednesday, December 9, 2015 7:26 AM
Hi Ron Chandler,
Since this issue is related to the VB language development, I help you move this case to the VB forum for dedicated support.
Best Regards,
Jack
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.