How do I get the phone number in Windows Mobile?

xiaoxiao2021-04-10  573

Some time ago, many friends asked, how to get the phone number. There is an IMSI (International Mobile Subscriber Identity) Record on the SIM card, but this is not a phone number. It is estimated that in the server side, the phone number corresponds to the IMSI, and the specific Record case can refer to the SIM GSM File System specification. Note: This article comes from Windows Mobile Team Blog. The code part has been tested (in Shanghai Mobile Network, Yitong Card), failed to get the phone number, may be the service provider without providing the service. Interested friends can refer to it.

#include "stdafx.h" #include "windows.h" #include "tapi.h" #include "tsp.h" #pragma Comment (lib, "cellcore.lib") #define exit_on_null (_p) / if (_p) == NULL) / {/ hr = e_OutofMemory; / goto funceXit; /} #define exit_on_false (_f) / if (! (_ F)) / {/ hr = e_fail; / goto funcexit; /} #define max (i, j) ((i)> (j) (i):? (j)) #define TAPI_API_LOW_VERSION 0x00020000 # define TAPI_API_HIGH_VERSION 0x00020000 #define CAPS_BUFFER_SIZE 512 HRESULT SHReadLineAddressCaps (LPTSTR szNumber, UINT cchNumber, PDWORD pdwCallFwdModes, UINT nLineNumber) {HRESULT hr = E_FAIL; LRESULT lResult = 0; hLINEAPP hLineApp; DWORD dwNumDevs; DWORD dwAPIVersion = TAPI_API_HIGH_VERSION; LINEINITIALIZEEXPARAMS liep; DWORD dwTAPILineDeviceID; const DWORD dwAddressID = nLineNumber - 1; liep.dwTotalSize = sizeof (liep); liep.dwOptions = LINEINITIALIZEEXOPTION_USEEVENT; if (SUCCEEDED (LineInitializeex (& HlineApp, 0, 0, Text ("ExtApi_Lib"), & DWNU mDevs, & dwAPIVersion, & liep))) {BYTE * pCapBuf = NULL; DWORD dwCapBufSize = CAPS_BUFFER_SIZE; LINEEXTENSIONID LineExtensionID; LINEDEVCAPS * pLineDevCaps = NULL; LINEADDRESSCAPS * placAddressCaps = NULL; pCapBuf = new BYTE [dwCapBufSize]; EXIT_ON_NULL (pCapBuf); pLineDevCaps = (LINEDEVCAPS *) pCapBuf; pLineDevCaps-> dwTotalSize = dwCapBufSize; // Get TSP Line Device ID dwTAPILineDeviceID = 0xffffffff; for (DWORD dwCurrentDevID = 0; dwCurrentDevID

) {If (0 == lineNegotiateAPIVersion (hLineApp, dwCurrentDevID, TAPI_API_LOW_VERSION, TAPI_API_HIGH_VERSION, & dwAPIVersion, & LineExtensionID)) {lResult = lineGetDevCaps (hLineApp, dwCurrentDevID, dwAPIVersion, 0, pLineDevCaps); if (dwCapBufSize dwNeededSize) {delete [ ] pCapBuf; dwCapBufSize = pLineDevCaps-> dwNeededSize; pCapBuf = new BYTE [dwCapBufSize]; EXIT_ON_NULL (pCapBuf); pLineDevCaps = (LINEDEVCAPS *) pCapBuf; pLineDevCaps-> dwTotalSize = dwCapBufSize; lResult = lineGetDevCaps (hLineApp, dwCurrentDevID, dwAPIVersion, 0, PLINEDEVCAPS);} IF ((0 == LRESULT) && (0 == _TCSCMP ((Byte *) PLINEDEVCAPS PLINEDEVCAPS-> DWLINENAMEOFFSET, CELLTSP_LINENAME_STRING)) {dwtap ILineDeviceID = dwCurrentDevID; break;}}} placAddressCaps = (LINEADDRESSCAPS *) pCapBuf; placAddressCaps-> dwTotalSize = dwCapBufSize; lResult = lineGetAddressCaps (hLineApp, dwTAPILineDeviceID, dwAddressID, dwAPIVersion, 0, placAddressCaps); if (dwCapBufSize dwNeededSize) {Delete [] PCAPBUF; dwcapbufsize = placheddresscaps-> dwneedededsize; pcapbuf = new byte [dwcapbufsize]; exit_on_null (pcapbuf); PlacAddressCaps = (lineaddresscaps *) PCAPBUF;

转载请注明原文地址:https://www.9cbs.com/read-133500.html

New Post(0)