Click here to Skip to main content
Click here to Skip to main content

Mobile development

, 7 Sep 2010
Rate this:
Please Sign up or sign in to vote.
A simple taskbar addon showing the WiFi signal strength
  • TaskbarAddon5 - Windows Mobile taskbar addon showing the signal strength of associated access point (Hits: 0, size: 178.63 KB)

Here is one more Windows mobile taskbar addon. I have seen that many people are interested in these small widgets. This one shows the signal strength of the current associated access point in your taskbar.

The code is the same as with the other taskbaraddons you find here, only the code for wireless signal strength has been added. Oh, yes, and this addon uses small bitmaps to show the signal strength.

To get the signal strength, I use part of PeekPocket code submission at CodeProject. I only need the name of the first wireless adapter.

CWifiPeek m_wp;
TCHAR* szAdapterName=new TCHAR[64];
 
ULONG GetCurrentValue(){
    WCHAR buf[1024];
    DWORD dwSize;
    dwSize=sizeof(buf);
    if(false == m_wp.GetAdapters(buf, dwSize) || dwSize == 0)
    {
        return UNKNOWERROR;
    }
    else{
        //we are only interested in first returned name
        wsprintf(szAdapterName, L"%s", buf);
        int iRSSI=0;
        int iRes = GetSignalStrength(szAdapterName, &iRSSI);
        if(iRes == ERROR_SUCCESS){
            return iRSSI;
        }
        else{
            return LOADLIBFAILED;
        }
    }
}

(http://www.codeproject.com/KB/windows/PeekPocket.aspx)

Then the signal strength is queried using another code snippet:

INT GetSignalStrength(TCHAR *ptcDeviceName, INT *piSignalStrength)
{
    PNDISUIO_QUERY_OID queryOID;
    DWORD dwBytesReturned = 0;
    UCHAR QueryBuffer[sizeof(NDISUIO_QUERY_OID)+sizeof(DWORD)];
    HANDLE ndisAccess = INVALID_HANDLE_VALUE;
    BOOL retval;
    INT hr;
 
    // Attach to NDISUIO.
    ndisAccess = CreateFile(NDISUIO_DEVICE_NAME, 0, 0, NULL,
    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
    INVALID_HANDLE_VALUE );
 
    if (ndisAccess == INVALID_HANDLE_VALUE)
        return -1;
 
    // Get Signal strength
    queryOID = (PNDISUIO_QUERY_OID)&QueryBuffer[0];
    queryOID->ptcDeviceName = ptcDeviceName;
    queryOID->Oid = OID_802_11_RSSI;
 
    retval = DeviceIoControl(ndisAccess,
    IOCTL_NDISUIO_QUERY_OID_VALUE, (LPVOID)queryOID,
    sizeof(NDISUIO_QUERY_OID) + sizeof(DWORD), (LPVOID)queryOID,
    sizeof(NDISUIO_QUERY_OID) + sizeof(DWORD), &dwBytesReturned, NULL);
 
    if (retval && piSignalStrength)
    {
        hr = 0;
        *piSignalStrength = *(DWORD *)&queryOID->Data;
    }
    else
    {
        hr = -2;
    }
 
    CloseHandle(ndisAccess);
 
    return(hr);
}

(http://www.pcreview.co.uk/forums/thread-1306359.php)

<!-- Social Bookmarks BEGIN -->

<!-- Social Bookmarks END -->

License

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

About the Author

hjgode

Germany Germany
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 7 Sep 2010
Article Copyright 2010 by hjgode
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid