From: jp2msft on 20 Aug 2008 09:30 Same question, but for VB or C#? (I often read these newsgroups to catch How-To ideas, and I'd been wanting to do this for a while) "Chris Tacke, MVP" wrote: > Using what programming language? > > > -- > > Chris Tacke, Embedded MVP > OpenNETCF Consulting > Giving back to the embedded community > http://community.OpenNETCF.com > > "Skiler" <sklyar.andriy(a)gmail.com> wrote in message > news:360beca3-7d24-4c37-8760-82e77ff6745a(a)z11g2000prl.googlegroups.com... > >H all, > > I need to find WiFicard on my PocketPC on WM 5/6 and then to measure > > WIFI signal strength. > > Can smb provide me some help??? > > Thanks a lot! >
From: Skiler on 27 Aug 2008 09:16 I've resolved this issue. This peace of code is for people who have the same issue =)) Thanks all for replies..... HANDLE hDev; //already opened? if(m_hNDUIO != NULL) { return true; } hDev=CreateFile(NDISUIO_DEVICE_NAME, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, INVALID_HANDLE_VALUE); if(hDev == INVALID_HANDLE_VALUE) { return false; } else { m_hNDUIO=hDev; //return true; } HANDLE hFile; BYTE Buffer1[2048]; void *pvBuf; WCHAR TmpBuf[1024]; WCHAR *pszOut; DWORD dwRet; bool retval; WCHAR pAdapterName[1024]; DWORD dwBufSizeBytes = 1024; if(pAdapterName == NULL || dwBufSizeBytes < sizeof(WCHAR)) { GxPrintf(eGxDebugLog, "ASL: pAdapterName == NULL || dwBufSizeBytes < sizeof(WCHAR)\n"); dwBufSizeBytes=0; return false; } retval=false; //open NDIS driver hFile=CreateFile(L"NDS0:", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, INVALID_HANDLE_VALUE); if(hFile != INVALID_HANDLE_VALUE) { GxPrintf(eGxDebugLog, "ASL: CreateFile - success\n"); pvBuf=(void *)(&Buffer1[0]); dwRet=sizeof(Buffer1); if(DeviceIoControl(hFile, IOCTL_NDIS_GET_ADAPTER_NAMES, NULL, 0, pvBuf, sizeof(Buffer1), &dwRet, NULL)) { //adapter list ok. LPWSTR pszStr; dwRet=0; pszOut=TmpBuf; //no string classes used, so no MFC or ATL dependency. for(pszStr=(LPWSTR)pvBuf; *pszStr; pszStr+=wcslen(pszStr)+1) { //check if adapter name is ok, skip infrared, gprs, ActiveSync etc. if(wcsicmp(pszStr, L"ASYNCMAC1") && \ wcsicmp(pszStr, L"IRSIR1") && \ wcsicmp(pszStr, L"L2TP1") && \ wcsicmp(pszStr, L"PPTP1") && \ wcsicmp(pszStr, L"RNDISFN1") && \ wcsicmp(pszStr, L"WWAN1") && \ wcsicmp(pszStr, L"XSC1_IRDA1")) { //not the first adapter? if(pszOut != TmpBuf) { //append separator wcscat(pszOut, L","); pszOut++; dwRet+=sizeof(WCHAR); } wcscpy(pszOut, pszStr); pszOut+=wcslen(pszStr); dwRet+=sizeof(WCHAR) * wcslen(pszStr); } } //return required buffer size anyway dwBufSizeBytes=dwRet; //if buffer large enough, copy adapter names if(dwBufSizeBytes >= dwRet) { wcsncpy(pAdapterName, TmpBuf, dwRet); retval=true; } //otherwise will return false //.. } } BSSIDInfo pBSSIDInfo[128]; dwBufSizeBytes=sizeof(pBSSIDInfo); DWORD dwReturnedItems = 0; PNDISUIO_QUERY_OID pNQO; DWORD dwBytesRet; BYTE Buffer2[8192], *pByte; PNDIS_802_11_BSSID_LIST pList; int i; if(pBSSIDInfo == NULL) { GxPrintf(eGxDebugLog, "ASL: pBSSIDInfo == NULL\n"); dwReturnedItems=0; return false; } pNQO=(PNDISUIO_QUERY_OID)Buffer2; pNQO->ptcDeviceName = pAdapterName; pNQO->Oid=OID_802_11_BSSID_LIST; // Run query dwBytesRet = 0; if(!DeviceIoControl(m_hNDUIO, IOCTL_NDISUIO_QUERY_OID_VALUE, (void *)pNQO, 8192, (void *)pNQO, 8192, &dwBytesRet, NULL)) { return false; } else { pList=(PNDIS_802_11_BSSID_LIST)&pNQO->Data; dwReturnedItems=pList->NumberOfItems; //first item in array PNDIS_WLAN_BSSID pItem=pList->Bssid; for(i=0; i<pList->NumberOfItems; i++) { memcpy(pBSSIDInfo[i].BSSID, pItem->MacAddress, sizeof(pItem- >MacAddress)); mbstowcs(pBSSIDInfo[i].SSID, (char *)pItem->Ssid.Ssid, sizeof(pItem- >Ssid.Ssid)); pBSSIDInfo[i].RSSI=pItem->Rssi; if(pItem->Configuration.DSConfig > 14) { pBSSIDInfo[i].Channel=(pItem->Configuration.DSConfig - 2407000) / 5000; } else { pBSSIDInfo[i].Channel=pItem->Configuration.DSConfig; } pBSSIDInfo[i].Auth=pItem->Privacy; pBSSIDInfo[i].Infastructure=pItem->InfrastructureMode; //some pointer magic...actually pItem->Length was not sizeof(NDIS_WLAN_BSSID) //so use returned length pByte=(BYTE *)pItem; pByte+=pItem->Length; pItem=(PNDIS_WLAN_BSSID)pByte; }//for } CloseHandle(m_hNDUIO); m_hNDUIO=NULL; return retval;
From: jp2msft on 28 Aug 2008 09:32 Thanks Skiler! I'm studying that now. "Skiler" wrote: > This peace of code is for people who have the same issue =))
First
|
Prev
|
Pages: 1 2 Prev: How can I remove notification of new SMS Next: Connecting to WEP using opennetcf SDF2.2 |