Home All Groups Group Topic Archive Search About
Author
1 May 2009 6:54 PM
hari
Hi all,

I am trying to use WlanConnect to a connect to a ad-hoc network. I am
getting the error invalid parameter.

I know the ssid of the ad-hoc network and wanna connect to it using the ssid
and not the profile name. It is an unsecure network. I found samples on the
net to connect to wifi network using the profile name and tat works for me..
but I want to connect using the SSID...

Here is the code

WLAN_CONNECTION_PARAMETERS wlanConnPara;

// set the connection mode
wlanConnPara.wlanConnectionMode = wlan_connection_mode_discovery_unsecure;

// set the profile name
wlanConnPara.strProfile = NULL;

// set the SSID
DOT11_SSID Ssid={0};
string strSsid = "harinetwork";
Ssid.uSSIDLength = (ULONG)strSsid.size();
memcpy(&Ssid.ucSSID, strSsid.c_str(), strSsid.size());

wlanConnPara.pDot11Ssid = &Ssid;

wlanConnPara.dot11BssType = dot11_BSS_type_independent;

// the desired BSSID list is empty
wlanConnPara.pDesiredBssidList = NULL;

// no connection flags
wlanConnPara.dwFlags = 0;

if((error = WlanConnect(hClient,&guid,&wlanConnPara,NULL)) == ERROR_SUCCESS)
{
    cout<<"Done"<<endl;
}
else
{
    cout<<"error "<<error<<endl;
}

Author
1 May 2009 11:18 PM
Jack [MVP-Networking]
Hi
Knowing the SSID of Ad-Hoc Network  does not mean that you can connect to
it.
There can be other element that are needed to configure, and in some cases
that can be a None computer device that you can not connect to at all.
Jack (MS, MVP-Networking)

Show quoteHide quote
"hari" <h***@discussions.microsoft.com> wrote in message
news:C722638B-8D5A-4CF6-A366-3959CF8F80A6@microsoft.com...
> Hi all,
>
> I am trying to use WlanConnect to a connect to a ad-hoc network. I am
> getting the error invalid parameter.
>
> I know the ssid of the ad-hoc network and wanna connect to it using the
> ssid
> and not the profile name. It is an unsecure network. I found samples on
> the
> net to connect to wifi network using the profile name and tat works for
> me..
> but I want to connect using the SSID...
>
> Here is the code
>
> WLAN_CONNECTION_PARAMETERS wlanConnPara;
>
> // set the connection mode
> wlanConnPara.wlanConnectionMode = wlan_connection_mode_discovery_unsecure;
>
> // set the profile name
> wlanConnPara.strProfile = NULL;
>
> // set the SSID
> DOT11_SSID Ssid={0};
> string strSsid = "harinetwork";
> Ssid.uSSIDLength = (ULONG)strSsid.size();
> memcpy(&Ssid.ucSSID, strSsid.c_str(), strSsid.size());
>
> wlanConnPara.pDot11Ssid = &Ssid;
>
> wlanConnPara.dot11BssType = dot11_BSS_type_independent;
>
> // the desired BSSID list is empty
> wlanConnPara.pDesiredBssidList = NULL;
>
> // no connection flags
> wlanConnPara.dwFlags = 0;
>
> if((error = WlanConnect(hClient,&guid,&wlanConnPara,NULL)) ==
> ERROR_SUCCESS)
> {
> cout<<"Done"<<endl;
> }
> else
> {
> cout<<"error "<<error<<endl;
> }