判断Pocket PC和Smartphone

    技术2022-05-11  14

    bool IsSupportPhone(){    const DWORD    TAPI_API_LOW_VERSION = 0x00020000;    const DWORD    TAPI_API_HIGH_VERSION = 0x00020000;

        bool    bResult = false;

        HRESULT  hr = E_FAIL;    LRESULT  lResult = 0;    HLINEAPP hLineApp;    DWORD    dwNumDevs;  //number of line devices    DWORD    dwAPIVersion = TAPI_API_HIGH_VERSION;    LINEINITIALIZEEXPARAMS liep;

        DWORD dwTAPILineDeviceID;    const DWORD dwAddressID = 0;

        liep.dwTotalSize = sizeof(liep);    liep.dwOptions   = LINEINITIALIZEEXOPTION_USEEVENT;

        if(SUCCEEDED(lineInitializeEx(&hLineApp, 0, 0, TEXT("ExTapi_Lib"), &dwNumDevs, &dwAPIVersion, &liep)))    {        BYTE* pCapBuf = NULL;        DWORD dwCapBufSize = 512;        LINEEXTENSIONID  LineExtensionID;        LINEDEVCAPS*     pLineDevCaps = NULL;

            pCapBuf = new BYTE[dwCapBufSize];

            pLineDevCaps = (LINEDEVCAPS*)pCapBuf;        pLineDevCaps->dwTotalSize = dwCapBufSize;

            // Get TSP Line Device ID        dwTAPILineDeviceID = 0xffffffff;

            for (DWORD dwCurrentDevID = 0 ; dwCurrentDevID < dwNumDevs ; dwCurrentDevID++)        {            //ensure TAPI, service provider, and application are all using the same versions            if (0 == lineNegotiateAPIVersion(hLineApp, dwCurrentDevID, TAPI_API_LOW_VERSION, TAPI_API_HIGH_VERSION,                &dwAPIVersion, &LineExtensionID))            {                lResult = lineGetDevCaps(hLineApp, dwCurrentDevID, dwAPIVersion, 0, pLineDevCaps);

                    //increase buffer size if too small to hold the device capabilities                if (dwCapBufSize < pLineDevCaps->dwNeededSize)                {                    delete[] pCapBuf;                    dwCapBufSize = pLineDevCaps->dwNeededSize;                    pCapBuf = new BYTE[dwCapBufSize];

                        pLineDevCaps = (LINEDEVCAPS*)pCapBuf;                    pLineDevCaps->dwTotalSize = dwCapBufSize;

                        lResult = lineGetDevCaps(hLineApp, dwCurrentDevID, dwAPIVersion, 0, pLineDevCaps);                }                //lResult of 0 means the device capabilities were successfully returned                if ((0 == lResult) &&                    (0 == _tcscmp((TCHAR*)((BYTE*)pLineDevCaps+pLineDevCaps->dwLineNameOffset), CELLTSP_LINENAME_STRING)))                {                    dwTAPILineDeviceID = dwCurrentDevID;                    bResult = true;                    break;                }            }         }

            delete [] pCapBuf;    }

        lineShutdown(hLineApp);

     

        return bResult;} 


    最新回复(0)