Click here to get back home

Getting device's telephone number

 HomeNewsGroups | Search | About
 microsoft.public.smartphone    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Getting device's telephone number Ravi 08-06-2007
Posted by Ravi on August 6, 2007, 12:52 pm
Please log in for more thread options
All,
I was trying to use the getphonenumber sample application which displays
the device's phone number. This works fine on a WM 5.0 device, but does not
on a WM 6.0 device (standard or professional). The API used
lineGetAddressCaps() returns address size as 0.

What am I missing? Are there any alternative ways of getting the phone
number? Appending the getphone number main code at the end of the mail.

thanks in advance
ravi



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('');

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;
}


Similar ThreadsPosted
Get my SmartPhone number March 8, 2006, 4:55 am
Number formating on WM5 May 11, 2006, 10:18 am
Dial number from Outlook December 13, 2005, 1:08 pm
How do I set phone number priority? May 4, 2006, 8:03 am
Sending E-Mail to a Number December 4, 2006, 7:09 am
increasing number of call history October 22, 2005, 1:08 pm
Answer phone number doesn't stay put January 21, 2006, 8:24 pm
dial number in contacts note April 5, 2006, 9:06 am
Finding a number with Windows Explorer November 14, 2006, 10:51 pm
Finding a number with Windows Explorer November 16, 2006, 2:20 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap