Hi,
I'm trying to get the my own phone number from a POCKET PC 2003, in which I placed my SIM CARD. But I can't find the appropriate function. Is there a function doing this
Thanks
Hi,
I'm trying to get the my own phone number from a POCKET PC 2003, in which I placed my SIM CARD. But I can't find the appropriate function. Is there a function doing this
Thanks
Getting own phone number or SMS Service Number from a POCKET PC
Elijah Niño D. Mondero
be sure to debug the example in PHONE version emulator ;)
but more probably phone number is not stored in emultor
mcmathys04
I re-wrote this in C#, and for wm6 based pocketpc phones I get an empty string for the phone number. I get a dwAddressOffset of 228 and a leng of 2 (a unicode null terminator).
Running GetPhoneNumber.exe from the WM6 SDK has the same problem.
Any hints as to how to get the phone number out of the phone Is it possible at all
Pvanroos
I really doubt if its possible. cuz the code specifically mentions that it works only if the SIM card has the phone number programmed into it, which in most cases it not so.
Puzzl3b0x
This function doesn't work. I have tested on many devices and in most of the devices it doesnot retrive the number, it gives only "".
Roman Nurik
Thanks for your help but I need more explanation.
Can you tell me what are these parameters( LPTSTR szNumber, UINT cchNumber, UINT nLineNumber ) briefly
I am expecting your answer.
Matt Bastin
The problem on Pocket PC is that the Value of pLineDevCaps+pLineDevCaps->dwLineNameOffset is not equal to CELLTSP_LINENAME_STRING which has been set to "Cellular Line" is tsp.h of Pocketpc.
For Pocket PC below values of pLineDevCaps+pLineDevCaps->dwLineNameOffset are displayed:
Serial Cable on COM1:
Infrared Port
Bluetooth
Bluetooth device
Generic IrDA
Hayes Compatible on COM1:
But none still give the phone Number.
Does anyone know what must the value of CELLTSP_LINENAME_STRING be set for PocketPC in the tsp.h header file
Blackwood
Hi Gurhan,
take a look on lineGetAddressCaps function.
#define TAPI_API_LOW_VERSION 0x00020000
#define TAPI_API_HIGH_VERSION 0x00020000
#define CAPS_BUFFER_SIZE 512
HRESULT SHGetPhoneNumber(LPTSTR szNumber, UINT cchNumber, UINT nLineNumber)
{
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 = nLineNumber - 1;
liep.dwTotalSize = sizeof(liep);
liep.dwOptions = LINEINITIALIZEEXOPTION_USEEVENT;
//initialize line before accessing
if (SUCCEEDED(lineInitializeEx(&hLineApp, 0, 0, TEXT("ExTapi_Lib"), &dwNumDevs, &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 < 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];
EXIT_ON_NULL(pCapBuf);
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;
break;
}
}
}
placAddressCaps = (LINEADDRESSCAPS*)pCapBuf;
placAddressCaps->dwTotalSize = dwCapBufSize;
lResult = lineGetAddressCaps(hLineApp, dwTAPILineDeviceID, dwAddressID, dwAPIVersion, 0, placAddressCaps);
//increase buffer size if too small to hold the address capabilities
if (dwCapBufSize < placAddressCaps->dwNeededSize)
{
delete[] pCapBuf;
dwCapBufSize = placAddressCaps->dwNeededSize;
pCapBuf = new BYTE[dwCapBufSize];
EXIT_ON_NULL(pCapBuf);
placAddressCaps = (LINEADDRESSCAPS*)pCapBuf;
placAddressCaps->dwTotalSize = dwCapBufSize;
lResult = lineGetAddressCaps(hLineApp, dwTAPILineDeviceID, dwAddressID, dwAPIVersion, 0, placAddressCaps);
}
//lResult of 0 means the address capabilities were successfully returned
if (0 == lResult)
{
if (szNumber)
{
szNumber[0] = TEXT('\0');
EXIT_ON_FALSE(0 != placAddressCaps->dwAddressSize);
// A non-zero dwAddressSize means a phone number was found
ASSERT(0 != placAddressCaps->dwAddressOffset);
PWCHAR tsAddress = (WCHAR*)(((BYTE*)placAddressCaps)+placAddressCaps->dwAddressOffset);
StringCchCopy(szNumber, cchNumber, tsAddress);
}
hr = S_OK;
}
delete[] pCapBuf;
} // End if ()
FuncExit:
lineShutdown(hLineApp);
return hr;
}
example taken from WM5' SDK
I hope this help ;)
Timmy0614
szNumber could be a TCHAR[] variable (eg: TCHAR szNumber[255])
cchNumber is the szNumber's length (eg: 255 for szNumber[255])
nLineNumber is the line's number to open in TAPI
Please check the example in WM5' SDK (GetPhoneNumber)
Bye
Roger Lipscombe
Firstly, thanks for help. But there is a problem, in the function, dwAddressSize is always zero. So it can not find a phone number Is it something about nLineNumber Which other numbers should I try instead of 1 Also I got the example project but I can't run it because after a successful deployement, Visual Studio 2005 gives this error:
Unable to start program '%CSIDL_PROGRAM_FILES%\GetPhoneNumber\GetPhoneNumber.exe'
Thanks very much again.