Over the past few months, I have seen the requests for help retrieving the phone number on a Treo increase dramatically. In the vain hope that maybe this entry will get correctly indexed by Google (and therefore reduce the number of requests for help on the forums) I release this code to assist you however it may. As always, a quick note to let me know it helped you is appreciated but in no way required. Happy coding!
-Jon
///////////////////////////////////////////////////////
Char* number = NULL;
PhnAddressList list;
PhnAddressHandle address;
PhnLibOpen(phnLibRef);
if (IsCDMA())
{
Err err = PhnLibGetOwnNumbers(phnLibRef, &list);
if (!err)
{
err = PhnLibAPGetNth(phnLibRef, list, 1, &address);
if (!err && address)
{
number = PhnLibAPGetField(phnLibRef,
address,
phnAddrFldPhone);
MemHandleFree(address);
}
}
}
else
{
Err err = PhnLibGetOwnNumbers(phnLibRef, &list);
if (!err)
{
err = PhnLibGetNth(phnLibRef, list, 1, &address);
if (!err && address)
{
number = PhnLibGetField(phnLibRef,
address,
phnAddrFldPhone);
MemHandleFree(address);
}
}
}
if (number)
{
StrCopy(destNumber,number);
MemPtrFree (number);
}
|