none
심카드 변경 유/무 알기 RRS feed

  • 질문

  • 심카드가 변경되었다는 것은 IMSI 번호가 변경되었다는 것으로 다음 함수를 이용하여 데이터를 읽고 변경이 되었다는 것을 알 수 있습니다.

    // *******************************************************************
    // This function initializes ExTAPI and then calls lineGetGeneralInfo.
    // It then takes the info that lGGI returned and gets the IMSI number.
    // *******************************************************************
    BOOL GetExTAPIInfo()
    {
        HINSTANCE g_hInstance;
        TCHAR gszFriendlyAppName[160];
        DWORD dwNumDevs;
        DWORD dwAPIVersion = TAPI_API_HIGH_VERSION;
        LINEINITIALIZEEXPARAMS liep;
        HLINEAPP hLineApp = 0;
        HLINE hLine = 0;
        DWORD dwExtVersion;
        BOOL bRetVal = FALSE;
        LPBYTE pLineGeneralInfoBytes = NULL;
        DWORD dwTAPILineDeviceID;
        const
    DWORD dwMediaMode = LINEMEDIAMODE_DATAMODEM | LINEMEDIAMODE_INTERACTIVEVOICE;
        LINEGENERALINFO lviGeneralInfo;
        LPLINEGENERALINFO plviGeneralInfo;
        g_hInstance = GetModuleHandle(NULL
    );
        // Get the friendly application name from the STRINGTABLE
        LoadString(g_hInstance, IDS_FRIENDLYNAME, gszFriendlyAppName, ARRAY_LENGTH(gszFriendlyAppName));
        // set the line init params
        liep.dwTotalSize = sizeof
    (liep);
        liep.dwOptions = LINEINITIALIZEEXOPTION_USEEVENT;
        if
    (lineInitializeEx(&hLineApp, 0, 0, gszFriendlyAppName,
                &dwNumDevs, &dwAPIVersion, &liep)) 
        {
            goto
    cleanup;
        }
        // get the device ID
        dwTAPILineDeviceID = GetTSPLineDeviceID(hLineApp, dwNumDevs, 
                                                                    TAPI_API_LOW_VERSION, 
                                                                    TAPI_API_HIGH_VERSION, 
                                                                    CELLTSP_LINENAME_STRING);
        // error getting the line device ID?
        if
    (0xffffffff == dwTAPILineDeviceID) 
        {
            goto
    cleanup;
        }
       

        // now try and open the line
        if
    (lineOpen(hLineApp, dwTAPILineDeviceID, 
                            &hLine, dwAPIVersion, 0, 0, 
                            LINECALLPRIVILEGE_OWNER, dwMediaMode, 0)) 
        {
            goto
    cleanup;
        }
       

        // set up ExTAPI
        if
    (lineNegotiateExtVersion(hLineApp, dwTAPILineDeviceID, 
                            dwAPIVersion, EXT_API_LOW_VERSION, 
                            EXT_API_HIGH_VERSION, &dwExtVersion)) 
        {
            goto
    cleanup;
        }
       

        // try to get the general info
        lviGeneralInfo.dwTotalSize = sizeof
    (lviGeneralInfo);
       

        // step 1: find out how much space we need
        if
    (lineGetGeneralInfo(hLine, &lviGeneralInfo)) 
        {
            goto
    cleanup;
        }
       

        // step 2: malloc space for all the info we need
        pLineGeneralInfoBytes = new
    BYTE[lviGeneralInfo.dwNeededSize];
        plviGeneralInfo = (LPLINEGENERALINFO)pLineGeneralInfoBytes;
       

        // step 3: call lGGI again with the appropriately sized buffer
        if
    (NULL != pLineGeneralInfoBytes) 
        {
            plviGeneralInfo->dwTotalSize = lviGeneralInfo.dwNeededSize;
            if
    (lineGetGeneralInfo(hLine, plviGeneralInfo)) 
            {
                goto
    cleanup;
            }
        }
        else

        }
           
    goto cleanup;
        }
       

        // step 4: cast all the arguments to strings
        if
    (plviGeneralInfo->dwSubscriberNumberOffset > 0)
        {
            WCHAR wimsi[50];
            char imsi[20];  // Where the IMSI is stored
           
    int i = 0;
            for (i = 0; i < (signed
    )(plviGeneralInfo->dwSubscriberNumberSize/2); i++)
            wimsi[ i] = *((
    unsigned short
    *)(plviGeneralInfo) + i + plviGeneralInfo->dwSubscriberNumberOffset/2);
            wimsi[ i]=NULL;
            WideCharToMultiByte(GetACP(),NULL,wimsi,-1,imsi,50,NULL,NULL);
        }
        else
        {
            // Failed to read IMSI
        }
        bRetVal = TRUE;
        cleanup:
            if (pLineGeneralInfoBytes) delete
    [] pLineGeneralInfoBytes;
            if
    (hLine) lineClose(hLine);
            if
    (hLineApp) lineShutdown(hLineApp);
        return
    bRetVal;
    }


    // ***************************************************************************
    // Function Name: GetTSPLineDeviceID
    //
    // Purpose: To get a TSP Line Device ID
    //
    // Arguments:
    // hLineApp = the HLINEAPP returned by lineInitializeEx
    // dwNumberDevices = also returned by lineInitializeEx
    // dwAPIVersionLow/High = min version of TAPI that we need
    // psTSPLineName = "Cellular Line"
    //
    // Return Values: Current Device ID
    //
    // Description:
    // This function returns the device ID of a named TAPI TSP. The Device ID is
    // used in the call to lineOpen
    // ***************************************************************************
    DWORD GetTSPLineDeviceID(const
    HLINEAPP hLineApp, 
                                            const
    DWORD dwNumberDevices, 
                                            const
    DWORD dwAPIVersionLow, 
                                            const
    DWORD dwAPIVersionHigh, 
                                            const TCHAR* const
    psTSPLineName)
    {
        DWORD dwReturn = 0xffffffff;
        for
    (DWORD dwCurrentDevID = 0 ; dwCurrentDevID < dwNumberDevices ; dwCurrentDevID++)
        {
            DWORD dwAPIVersion;
            LINEEXTENSIONID LineExtensionID;
            if
    (0 == lineNegotiateAPIVersion(hLineApp, dwCurrentDevID, 
                                    dwAPIVersionLow, dwAPIVersionHigh, 
                                    &dwAPIVersion, &LineExtensionID)) 
            {
                LINEDEVCAPS LineDevCaps;
                LineDevCaps.dwTotalSize =
    sizeof
    (LineDevCaps);
                if
    (0 == lineGetDevCaps(hLineApp, dwCurrentDevID, 
                                                dwAPIVersion, 0, &LineDevCaps)) 
                {
                    BYTE* pLineDevCapsBytes =
    new
    BYTE[LineDevCaps.dwNeededSize];
                    if
    (0 != pLineDevCapsBytes) 
                    {
                        LINEDEVCAPS* pLineDevCaps = (LINEDEVCAPS*)pLineDevCapsBytes;
                        pLineDevCaps->dwTotalSize = LineDevCaps.dwNeededSize;
                        if
    (0 == lineGetDevCaps(hLineApp, dwCurrentDevID, 
                                        dwAPIVersion, 0, pLineDevCaps)) 
                        {
                            if
    (0 == _tcscmp((TCHAR*)((BYTE*)pLineDevCaps+pLineDevCaps->dwLineNameOffset), 
                                        psTSPLineName)) 
                            {
                                dwReturn = dwCurrentDevID;
                            }
                        }
                        delete
    [] pLineDevCapsBytes;
                    }
                }
            }
        }
        return
    dwReturn;
    }

    http://social.msdn.microsoft.com/forums/en-US/vssmartdevicesnative/thread/b2307030-2d5b-4f12-aeb8-662655f16086/

    • 이동됨 Alicia CalesMicrosoft employee 2010년 4월 14일 수요일 오전 7:03 Forums Consolidation (이전 위치:Smart Devices Native C++ Development)
    2010년 1월 12일 화요일 오전 2:21