Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C
Hello
 
I am trying to write a program to connect to wifi routers/ap. I have been successfull into connecting to open networks.
 
However when i try to connect to secured networks, a baloon pop up asking for password. Can i not pass the password automatically.
 
My code is as below. Can someone modify this to work for secured network. My APs does not have any profile names.
	/* Client opens a handle for connection */
	status = WlanOpenHandle( WLAN_API_VERSION, NULL, &dwCurVersion,&hClient );
	
	/* Get the list of wi-fi interfaces */
	status = WlanEnumInterfaces(hClient, NULL, &pIfList);
	
		pIfInfo = (WLAN_INTERFACE_INFO *) &pIfList->InterfaceInfo[0];
 
	
	/* Get the list of visible networks */
		status = WlanGetAvailableNetworkList (hClient,&pIfInfo->InterfaceGuid,0,NULL,&pBssList);
		
		for (tmploop = 0; tmploop < pBssList->dwNumberOfItems; tmploop++) 
		{
			pBssEntry = (WLAN_AVAILABLE_NETWORK *) & pBssList->Network[tmploop];
			if (pBssEntry->dot11Ssid.uSSIDLength != 0)
			{
				
				strcpy(tmpBuffer,(char *) pBssEntry->dot11Ssid.ucSSID );   
			
				/* Whether the HOST to be connected is found ? */
				if(strcmp(tmpBuffer,"2WIRE472") == 0)
				{
					//hostFoundflag = SET;
					wlanConnPara.wlanConnectionMode = wlan_connection_mode_discovery_secure;//wlan_connection_mode_discovery_unsecure;
					wlanConnPara.strProfile = pBssEntry->strProfileName;  
					strcpy( (char *)(infoForSSID.ucSSID), tmpBuffer);
					infoForSSID.uSSIDLength = pBssEntry->dot11Ssid.uSSIDLength; 
					wlanConnPara.pDot11Ssid =&infoForSSID;
					wlanConnPara.pDesiredBssidList = NULL;
					wlanConnPara.dot11BssType = pBssEntry->dot11BssType; 
					wlanConnPara.dwFlags = pBssEntry->dwFlags;												
 
					/* Connect to the host */
					status = WlanConnect( hClient, &pIfInfo->InterfaceGuid, &wlanConnPara, NULL );
					
				}
			}
		}
Thanks
Nishith
Posted 6-Oct-12 15:01pm
Edited 6-Oct-12 18:30pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,518
1 Tadit Dash 350
2 Manas Bhardwaj 319
3 OriginalGriff 243
4 Sergey Alexandrovich Kryukov 240
0 Sergey Alexandrovich Kryukov 9,530
1 OriginalGriff 5,716
2 Peter Leow 4,320
3 Maciej Los 3,540
4 Abhinav S 3,373


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 7 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid