[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode)]
public struct WLAN_CONNECTION_PARAMETERS
{
public WLAN_CONNECTION_MODE wlanConnectionMode;
public string strProfile;
public DOT11_SSID[] pDot11Ssid;
public DOT11_BSSID_LIST[] pDesiredBssidList;
public DOT11_BSS_TYPE dot11BssType;
public uint dwFlags;
}
Structure WLAN_CONNECTION_PARAMETERS
Public TODO
End Structure
None.
To people who just run into this page :
The history of this shows that IntPtrs for pDot11Ssid and pDesiredBssidList were changed to DOT11_SSID[] and DOT11_LIST[]. Then it should have some kind of explanation about the reason.
I think whether to use IntPtr or DOT11_SSID[] etc should be determined by which one you want, "Marshal" or "UnMarshal".
The rationale behind the change in the history for this is because is that he/she wanted to "unmarshal". However, in functions like WlanConnect(), it is used as an "input". So, it needs to be marshaled. Then I believe they should be IntPtr.
Also, DOT11_SSID[] looks to be wrong. It is to point one "SSID" not a series of SSID.
Also, it would be great if it explains how to marshal ucSSID in DOT11, because the ucSSID is just ANSI string ( without the terminating '\0'. )
>>Here is a simple way to marshal the DOT11_SSID structure. This uses Marshal.AllocHGlobal but you could also use Marshal.StructureToPtr.
int ssidSize = 4 + 32;
IntPtr ssidSpace = Marshal.AllocHGlobal(ssidSize);
byte[] ssidTextBytes = Encoding.ASCII.GetBytes("My SSID");
Marshal.WriteInt32(ssidSpace, ssidTextBytes.Length);
for (int i = 0; i < ssidTextBytes.Length; i++)
Marshal.WriteByte(ssidSpace, 4 + i, ssidTextBytes[i]);
wcp.pDot11Ssid = ssidSpace;
...
Marshal.FreeHGlobal(ssidSpace);